
var vhidApplicationPath;
var vddlCarOwner, vtxtCarOwner2 , vtxtArCarOwner2, vtxtCarOwnerTel, vddlCarOwnerType;

// Changes the cursor to hand
//***************************
function OnMouseOver( vControl )
{

	try
	{
		var varControl ;
		varControl = document.getElementById( vControl );
		varControl.style.textDecorationUnderline = true;
		varControl.style.cursor = 'hand';
		//vControl.className = "MnuText_Over";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOut( vControl )
{
	try
	{
		var varControl ;
		varControl = document.getElementById( vControl );
		varControl.style.textDecorationUnderline = false;
		//varControl.className = "MnuText_Out";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOver_H( vControl )
{
	try
	{
		vControl.style.textDecorationUnderline = true;
		vControl.style.cursor = 'hand';
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOver_H( vControl )
{
	try
	{
		vControl.style.textDecorationUnderline = false;
		vControl.style.cursor = 'hand';
		vControl.className = "MnuText_OutHomeTopOver";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOut_H( vControl )
{
	try
	{
		vControl.style.textDecorationUnderline = false;
		vControl.className = "MnuText_OutHomeTop";
		
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOut_HC( vControl )
{
	try
	{
		vControl.style.textDecorationUnderline = false;
		vControl.className = "MnuText_OutHome1";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}
function OnMouseOverHome( vControl )
{
	try
	{
		vControl.style.cursor = 'hand';
		vControl.className = "MnuText_OverHome";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}


function OnMouseOutHome( vControl )
{
	try
	{
		vControl.className = "MnuText_OutHome";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}


// Get the application path
//***************************
function GetApplicationPath()
{
	try
	{
		vhidApplicationPath = document.getElementById( "__hhidApplicationPath" );
	}
	catch( ex )
	{}
}


// Open page in same window
//***************************
function OpenPageInSameWindow( vTargetPage )
{
	// Get the Applcation Path Hidden Field
	GetApplicationPath();
	
	// Open the Page
	window.location = vhidApplicationPath.value + vTargetPage;
}

function OnMouseOut_Buttons( vControl )
{
	try
	{
		vControl.className = "MnuText_OutIN";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOver_Buttons( vControl )
{
	try
	{
		vControl.style.cursor = 'hand';
		vControl.className = "MnuText_OverIN";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}


// Swap image and cursor
//***************************
function SwapImageAndCursor( vControl, imgImagetoReplace , blnOver )
{
	// Get the Applcation Paht Hidden Field
	GetApplicationPath();
	
	if( ! vhidApplicationPath )
	{
		//alert( "Does not inherit BaseClass" );
		return;
	}
	//alert(vControl);
	// Change the Mouse Cursor
	if ( blnOver )
	
		vControl.style.cursor = 'hand';
	else
		vControl.style.cursor = 'default';

	// Set the New Image
	vControl.src = vhidApplicationPath.value + "/" + imgImagetoReplace;
}

// Swap image and cursor
//***************************
function SwapImage( vControl, imgImagetoReplace , blnOver )
{
	// Get the Applcation Paht Hidden Field
	GetApplicationPath();
	
	if( ! vhidApplicationPath )
	{
		//alert( "Does not inherit BaseClass" );
		return;
	}
	
	// Change the Mouse Cursor
	
	// Set the New Image
	vControl.src = vhidApplicationPath.value + "/" + imgImagetoReplace;
}


// Movement and scrolling
//***************************
// New
	/*latest 7 */
	function lib_bwcheck7()
	{ //Browsercheck ( needed )
		this.ver=navigator.appVersion
		this.agent=navigator.userAgent
		this.dom=document.getElementById?1:0
		this.opera5=this.agent.indexOf( "Opera 5" )>-1
		this.ie5=( this.ver.indexOf( "MSIE 5" )>-1 && this.dom && !this.opera5 )?1:0; 
		this.ie6=( this.ver.indexOf( "MSIE 6" )>-1 && this.dom && !this.opera5 )?1:0;
		this.ie4=( document.all && !this.dom && !this.opera5 )?1:0;
		this.ie=this.ie4||this.ie5||this.ie6
		this.mac=this.agent.indexOf( "Mac" )>-1
		this.ns6=( this.dom && parseInt( this.ver ) >= 5 ) ?1:0; 
		this.ns4=( document.layers && !this.dom )?1:0;
		this.bw=( this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 )
		return this
	}
	var bw=new lib_bwcheck7()
	var speed7 = 30
	var loop7, timer7
	
	function makeObj7( obj , nest )
	{
		nest=( !nest ) ? "":'document.'+nest+'.'
		this.el=bw.dom?document.getElementById( obj ):bw.ie4?document.all[obj]:bw.ns4?eval( nest+'document.'+obj ):0;
		this.css=bw.dom?document.getElementById( obj ).style:bw.ie4?document.all[obj].style:bw.ns4?eval( nest+'document.'+obj ):0;
		this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetHeight
		this.clipHeight=bw.ns4?this.css.clip.width:this.el.offsetHeight
		this.up=goUp7;
		this.down=goDown7;
		this.moveIt=moveIt;
		this.x=0;
		this.y=0;
		this.obj = obj + "Object"
		eval( this.obj + "=this" )
		return this
	}
	
	var px = bw.ns4||window.opera?"":"px";
	
	function moveIt( x,y )
	{
		this.x = x
		this.y = y
		this.css.left = this.x+px
		this.css.top = this.y+px
	}
	
	function goDown7( move )
	{
		if ( this.y > -2900 )
		{
			this.moveIt( 0,this.y-move )
			if ( loop7 )
				setTimeout( this.obj+".down( "+move+" )",speed7 )
		}
	}
	
	//Makes the object go down
	function goUp7( move )
	{
		if ( this.y<0 )
		{
			this.moveIt(0 ,this.y-move )
			if ( loop7 )
				setTimeout( this.obj+".up( "+move+" )",speed7 )
		}
	}
	
	//Calls the scrolling functions. Also checks whether the page is loaded or not.
	function scroll7( speed7 )
	{
		if ( scrolltextLoaded7 )
		{
			loop7 = true;
			if ( speed7 > 0 )
				oScroll7.down( speed7 );
			else
				oScroll7.up( speed7 );
		}
	}
	
	//Stops the scrolling ( called on mouseout )
	function noScroll7()
	{
		loop7 = false
		if ( timer7 )
			clearTimeout( timer7 );
	}
	
	//Makes the object
	var scrolltextLoaded7 = false
	
	function scrolltextInit7()
	{
		try
		{
		
			oCont7 = new makeObj7( 'divScrollTextCont7' );
			oScroll7 = new makeObj7( 'divText7','divScrollTextCont7' );
			oScroll7.moveIt( 0 , 0 );
			oCont7.css.visibility = "visible";
			scrolltextLoaded7 = true;
		}
		catch( ex )
		{
			alert( ex.message );
		}
	}
	
	
		/*latest 8 */
	function lib_bwcheck8()
	{ //Browsercheck ( needed )
		this.ver=navigator.appVersion
		this.agent=navigator.userAgent
		this.dom=document.getElementById?1:0
		this.opera5=this.agent.indexOf( "Opera 5" )>-1
		this.ie5=( this.ver.indexOf( "MSIE 5" )>-1 && this.dom && !this.opera5 )?1:0; 
		this.ie6=( this.ver.indexOf( "MSIE 6" )>-1 && this.dom && !this.opera5 )?1:0;
		this.ie4=( document.all && !this.dom && !this.opera5 )?1:0;
		this.ie=this.ie4||this.ie5||this.ie6
		this.mac=this.agent.indexOf( "Mac" )>-1
		this.ns6=( this.dom && parseInt( this.ver ) >= 5 ) ?1:0; 
		this.ns4=( document.layers && !this.dom )?1:0;
		this.bw=( this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5 )
		return this
	}
	var bw=new lib_bwcheck8()
	var speed8 = 30
	var loop8, timer8
	
	function makeObj8( obj,nest )
	{
		nest=( !nest ) ? "":'document.'+nest+'.'
		this.el=bw.dom?document.getElementById( obj ):bw.ie4?document.all[obj]:bw.ns4?eval( nest+'document.'+obj ):0;
		this.css=bw.dom?document.getElementById( obj ).style:bw.ie4?document.all[obj].style:bw.ns4?eval( nest+'document.'+obj ):0;
		this.scrollWidth=bw.ns4?this.css.document.width:this.el.offsetHeight
		this.clipHeight=bw.ns4?this.css.clip.width:this.el.offsetHeight
		this.up=goUp8;this.down=goDown8;
		this.moveIt=moveIt; this.x=0; this.y=0;
		this.obj = obj + "Object"
		eval( this.obj + "=this" )
		return this
	}
	
	var px = bw.ns4||window.opera?"":"px";
	
	function moveIt( x,y )
	{
		this.x = x
		this.y = y
		this.css.left = this.x+px
		this.css.top = this.y+px
	}

	
	function goDown8( move )
	{
		if ( this.x>-2600 )
		{
			this.moveIt( this.x-move,0 )
			if ( loop8 )
				setTimeout( this.obj+".down( "+move+" )",speed8 )
		}
	}
	//Makes the object go down
	function goUp8( move )
	{
		if ( this.x<0 )
		{
			this.moveIt( this.x-move,0 )
			if ( loop8 )
				setTimeout( this.obj+".up( "+move+" )",speed8 )
		}
	}
	
	//Calls the scrolling functions. Also checks whether the page is loaded or not.
	function scroll8( speed8 )
	{
		if ( scrolltextLoaded8 ){
			loop8 = true;
			if ( speed8>0 )
				oScroll8.down( speed8 )
			else
				oScroll8.up( speed8 )
		}
	}
	
	//Stops the scrolling ( called on mouseout )
	function noScroll8()
	{
		loop8 = false
		if ( timer8 )
			clearTimeout( timer8 )
	}
	//Makes the object
	var scrolltextLoaded8 = false
	function scrolltextInit8()
	{
		oCont8 = new makeObj8( 'divScrollTextCont8' )
		oScroll8 = new makeObj8( 'divText8','divScrollTextCont8' )
		oScroll8.moveIt( 0,0 )
		oCont8.css.visibility = "visible"
		scrolltextLoaded8 = true
	}

function TrimText(str)
{
	return( (""+str).replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );
}

function ConfirmDeletion( strItemName , blnIsUsed , strPageName)
{
	try
	{
		if( blnIsUsed == 'True' )
		{
			alert( "This " + strPageName + " is used and cannot be deleted!" );
			return false;
		}
		else
		{
			if( confirm( 'Are you sure you want to delete: "' + strItemName + '"?' ) )
			{
				return true;
			}
			else
				return false;
		}
	}
	catch( ex )
	{
	}
}

function ConfirmDeletionItem( strItemName )
{
	try
	{
		if( confirm( 'Are you sure you want to delete: "' + strItemName + '"?' ) )
		{
			return true;
		}
		else
			return false;
	}
	catch( ex )
	{
	}
}

function CannotBeEdited( strItemName , blnIsUsed , strPageName)
{
	try
	{
		if( blnIsUsed == 'True' )
		{
			alert( "This " + strPageName + " is online and cannot be edited!" );
			return false;
		}
		else
		{
			return true;
		}
		
	}
	catch( ex )
	{
	}
}

function ConfirmItemDeletion( strItemName , strItemCount )
{
	try
	{
		if( confirm( 'Are you sure you want to delete: "' + strItemName + '"?' ) )
		{
			if( parseInt( strItemCount ) > 0 ) 
			{
				alert( 'You cannot delete: "' + strItemName + '" because it is used' );
				return false;
			}
			else
				return true;
		}
	}
	catch( ex )
	{
	}
}

// HabeebS 23.01.2006
// *-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*
function OnMouseOverImg( vControl )
{
	try
	{
		vControl.parentElement.style.cursor = 'hand';
		vControl.parentElement.className = "BorderOn";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOutImg( vControl )
{
	try
	{
		vControl.parentElement.style.cursor = 'default';
		vControl.parentElement.className = "BorderOut";
	}
	catch( ex )
	{
		alert( 'OnMouseOutImg : ' + ex.message )
	}
}
// *-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*-+-*


function GetControlsByID()
{
	vddlCarOwner = document.getElementById( "wddlCarOwner" );
	vtxtCarOwner2 = document.getElementById( "wtxtCarOwner2" );
	vtxtArCarOwner2 = document.getElementById( "wtxtArCarOwner2" );
	vtxtCarOwnerTel = document.getElementById( "wtxtCarOwnerTel" );
	vddlCarOwnerType = document.getElementById( "wddlCarOwnerType" );
}

function CheckCarOwnerData()
{
	try
	{
		var strErrMsg;
		strErrMsg = "";
		
		// Get Controls by ID
		GetControlsByID();
		
		if( vddlCarOwnerType.value != -1 )
		{
			if( vddlCarOwnerType.value == 1 )
			{
				if( TrimText( vtxtCarOwner2.value ) == "" )
				{
					strErrMsg += "Please enter the car owner english name\n";
				}

				if( TrimText( vtxtArCarOwner2.value ) == "" )
				{
					strErrMsg += "Please enter the car owner arabic name\n";
				}

				if( TrimText( vtxtCarOwnerTel.value ) == "" )
				{
					strErrMsg += "Please enter the car owner telephone\n";
				}
			}
			else
			{
				if( vddlCarOwner.value == -1 )
				{
					strErrMsg += "Please select a car owner\n";
				}
			}
		}
		
		if( strErrMsg != "" )
		{
			alert( strErrMsg );
			return false;
		}
		
		return true;
	}
	catch( ex )
	{
		alert( ex.message );
	}
}


function GetCarOwnerControlsByID()
{
	vddlCarOwnerHomeTel = document.getElementById( "wtxtCarOwnerHomeTelNo" );
	vtxtCarOwnerOffTel = document.getElementById( "wtxtCarOwnerOfficeTelNo" );
	vtxtCarOwnerMob = document.getElementById( "wtxtCarOwnerMobileNo" );
}

function GetCarSellerControlsByID()
{
	vtxtCarOwnerTel = document.getElementById( "wtxtTelephone" );
	vtxtCarOwnerMob = document.getElementById( "wtxtMobile" );
	vtxtCarOwnerEmail = document.getElementById( "wtxtEmail" );
}


function ValidateCarOwnerMandatoryFields( source , arguments )
{
	try
	{
		// Get Controls
		GetCarOwnerControlsByID();

		if( 
			( TrimText( vddlCarOwnerHomeTel.value ) == "" ) &&
			( TrimText( vtxtCarOwnerOffTel.value ) == "" ) &&
			( TrimText( vtxtCarOwnerMob.value ) == "" ) 
			 )
		{
			arguments.IsValid = false;
		}
		else
		{
			arguments.IsValid = true;
		}
	}
	catch( ex )
	{
		alert( 'ValidateMandatoryFields : ' + ex.message );
	}	
}


function ValidateCarSellerMandatoryFields( source , arguments )
{
	try
	{
		// Get Controls
		GetCarSellerControlsByID();

		if( 
			( TrimText( vtxtCarOwnerTel.value ) == "" ) &&
			( TrimText( vtxtCarOwnerMob.value ) == "" ) &&
			( TrimText( vtxtCarOwnerEmail.value ) == "" ) 
			 )
		{
			arguments.IsValid = false;
		}
		else
		{
			arguments.IsValid = true;
		}
	}
	catch( ex )
	{
		alert( 'ValidateMandatoryFields : ' + ex.message );
	}	
}

function SelectAll()
{
	try
	{
		var vDGCars;
		var vCBSelect;
		var intCntr;
		var boolCheck;

		vDGCars = document.getElementById( "dgCars" );
		vCBSelect = document.getElementById( "ChkSelectAll" );

		if( vCBSelect.checked )
			boolCheck = true;
		else
			boolCheck = false;
		
		for( intCntr = 1 ; intCntr < vDGCars.children(0).children.length - 1 ; intCntr++ )
		{
			vDGCars.children(0).children(intCntr).children(0).children(0).checked = boolCheck
		}

	}
	catch( ex ){}
}

function ItemSelected( strRenDel )
{
	try
	{
		var intCntr;
		var vDGCars;
		vDGCars = document.getElementById( "dgCars" );
		var blnItemChecked;
		blnItemChecked = false;
		for( intCntr = 1 ; intCntr < vDGCars.children(0).children.length - 1 ; intCntr++ )
		{
			if( vDGCars.children(0).children(intCntr).children(0).children(0).checked )
			{
				blnItemChecked = true;
				break;
			}
		}
		
		if( !blnItemChecked )
		{
			alert( "There is no checked item to " + strRenDel );
			return false;
		}
		else
			return true;
	}
	catch( ex ){}	
}

function PowerWindowChecked()
{
	try
	{
		var vchkPowerWindows;
		vchkPowerWindows = document.getElementById( "ChkPowerWindows" );
		vchkFrontAndRearPowerWindows = document.getElementById( "ChkFrontAndRearPowerWindows" );
		var vSpan;
		vSpan = vchkFrontAndRearPowerWindows.parentElement;
		if( vchkPowerWindows.checked )
		{
			vchkFrontAndRearPowerWindows.disabled = false;
			vSpan.childNodes(1).style.color = "black";
		}
		else
		{
			vchkFrontAndRearPowerWindows.disabled = true;
			vchkFrontAndRearPowerWindows.checked = false;
			vSpan.childNodes(1).style.color = "gray";
		}
	}
	catch( ex ){}
}

function CheckManYear( source , arguments )
{
	try
	{
		var vManYearFrom, vManYearTo;
		vManYearFrom = document.getElementById( "wddlCarManYearFrom" );
		vManYearTo = document.getElementById( "wddlCarManYearTo" );
		
		if( vManYearFrom.selectedIndex != 0 )
		{
			if( vManYearTo.selectedIndex != 0 )
			{
				if( vManYearFrom.value > vManYearTo.value )
					arguments.IsValid = false;
				else
					arguments.IsValid = true;
			}
		}
	}
	catch( ex ){}
}


function CheckIfColorIsSelected( intColorSelected )
{
	try
	{
		var vddlExteriorColor1, vddlExteriorColor2, vddlExteriorColor3;
		vddlExteriorColor1 = document.getElementById( "wddlExteriorColor1" );
		vddlExteriorColor2 = document.getElementById( "wddlExteriorColor2" );
		vddlExteriorColor3 = document.getElementById( "wddlExteriorColor3" );

		if( intColorSelected == 1 )
		{
			if( vddlExteriorColor1.selectedIndex != 0 )
			{
				vddlExteriorColor2.disabled = false;
			}
			else
			{
				vddlExteriorColor2.disabled = true;
				vddlExteriorColor2.selectedIndex = 0;
				vddlExteriorColor3.disabled = true;
				vddlExteriorColor3.selectedIndex = 0;
			}
		}
		else if( intColorSelected == 2 )
		{
			if ( vddlExteriorColor2.selectedIndex != 0 )
			{
				vddlExteriorColor3.disabled = false;
			}
			else
			{
				vddlExteriorColor3.disabled = true;
				vddlExteriorColor3.selectedIndex = 0;
			}
		}
	}
	catch( ex )
	{
		alert( ex.message );
	}
}

function CheckIfPhotoIsFilled( intPhotoNo )
				{
					try
					
					{
					
						var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5, vfilePhoto6;
						vfilePhoto1 = document.getElementById( "fileCarPhotoToUpload" );
						vfilePhoto2 = document.getElementById( "fileCarPhoto2ToUpload" );
						vfilePhoto3 = document.getElementById( "fileCarPhoto3ToUpload" );
						vfilePhoto4 = document.getElementById( "fileCarPhoto4ToUpload" );
						vfilePhoto5 = document.getElementById( "fileCarPhoto5ToUpload" );
						vfilePhoto6 = document.getElementById( "fileCarPhoto6ToUpload" );
					
						if( intPhotoNo == 1 )
						{
							if ( (vfilePhoto1.value) != "" )
								{
								vfilePhoto2.disabled = false;
								}
							
						}
						
						if( intPhotoNo == 2 )
						{
							if ( (vfilePhoto1.value) != "" )
							{
								vfilePhoto2.disabled = false;
							}
							else
							{
								vfilePhoto2.disabled = true;
								vfilePhoto3.disabled = true;
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 3 )
						{
							if ( (vfilePhoto2.value) != "" )
							{
								vfilePhoto3.disabled = false;
							}
							else
							{
								vfilePhoto3.disabled = true;
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 4 )
						{
							if ( (vfilePhoto3.value) != "" )
							{
								vfilePhoto4.disabled = false;
							}
							else
							{
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 5 )
						{
							if ( (vfilePhoto4.value) != "" )
							{
								vfilePhoto5.disabled = false;
							}
							else
							{
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 6 )
						{
							if ( (vfilePhoto5.value) != "" )
							{
								vfilePhoto6.disabled = false;
							}
							else
							{
								vfilePhoto6.disabled = true;
							}
						}
					}
					catch( ex )
					{
						alert( ex.message );
					}
				}
				
function CheckFilledPhotos()
{
	try
	{
		        
		var strErrMsg;
		strErrMsg = "";
		
		// Get Controls by ID
		//GetControlsByID();
			var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5, vfilePhoto6;
			vfilePhoto1 = document.getElementById( "fileCarPhotoToUpload" );
			vfilePhoto2 = document.getElementById( "fileCarPhoto2ToUpload" );
			vfilePhoto3 = document.getElementById( "fileCarPhoto3ToUpload" );
			vfilePhoto4 = document.getElementById( "fileCarPhoto4ToUpload" );
			vfilePhoto5 = document.getElementById( "fileCarPhoto5ToUpload" );
			vfilePhoto6 = document.getElementById( "fileCarPhoto6ToUpload" );
		
		 if (TrimText(vfilePhoto6.value) != "")
		 {
		 
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == "") ||
                (TrimText(vfilePhoto3.value) == "") ||
                (TrimText(vfilePhoto4.value) == "") ||
                (TrimText(vfilePhoto5.value) == "")) 
                {
      
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }		
		 } 
                
		 if (TrimText(vfilePhoto5.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == "") ||
                (TrimText(vfilePhoto3.value) == "") ||
                (TrimText(vfilePhoto4.value) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
               
         if (TrimText(vfilePhoto4.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == "") ||
                (TrimText(vfilePhoto3.value) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		 
		 if (TrimText(vfilePhoto3.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == ""))
                
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		    
		  if (TrimText(vfilePhoto2.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == ""))
                              
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		
		//if( strErrMsg != "" )
		//{
			//alert( strErrMsg );
			//return false;
		//}
		
		return true;
	}
	catch( ex )
	{
		alert( ex.message );
	}
}

function CheckFilledPhotosDownloads()
{
	try
	{
		        
		var strErrMsg;
		strErrMsg = "";
		
		// Get Controls by ID
		//GetControlsByID();
			var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5;
			vfilePhoto1 = document.getElementById( "fileCarPhotoToUpload" );
			vfilePhoto2 = document.getElementById( "fileCarPhoto2ToUpload" );
			vfilePhoto3 = document.getElementById( "fileCarPhoto3ToUpload" );
			vfilePhoto4 = document.getElementById( "fileCarPhoto4ToUpload" );
			vfilePhoto5 = document.getElementById( "fileCarPhoto5ToUpload" );
			//vfilePhoto6 = document.getElementById( "fileCarPhoto6ToUpload" );
		
		
                
		 if (TrimText(vfilePhoto5.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == "") ||
                (TrimText(vfilePhoto3.value) == "") ||
                (TrimText(vfilePhoto4.value) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
               
         if (TrimText(vfilePhoto4.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == "") ||
                (TrimText(vfilePhoto3.value) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		 
		 if (TrimText(vfilePhoto3.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == "") ||
                (TrimText(vfilePhoto2.value) == ""))
                
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		    
		  if (TrimText(vfilePhoto2.value) != "")
		 {
		 if ((TrimText(vfilePhoto1.value) == ""))
                              
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		
		//if( strErrMsg != "" )
		//{
			//alert( strErrMsg );
			//return false;
		//}
		
		return true;
	}
	catch( ex )
	{
		alert( ex.message );
	}
}

/*function CheckIfImageIsFilled( intPhotoNo )
				{
					try
					
					{
					
						var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5, vfilePhoto6;
						vfilePhoto1 = document.getElementById( "ImgCarPhoto" );
						vfilePhoto2 = document.getElementById( "ImgCarPhoto2" );
						vfilePhoto3 = document.getElementById( "ImgCarPhoto3" );
						vfilePhoto4 = document.getElementById( "ImgCarPhoto4" );
						vfilePhoto5 = document.getElementById( "ImgCarPhoto5" );
						vfilePhoto6 = document.getElementById( "ImgCarPhoto6" );
					
						if( intPhotoNo == 1 )
						{
							if ( (vfilePhoto1.value) != "" )
								{
								vfilePhoto2.disabled = false;
								}
							
						}
						
						if( intPhotoNo == 2 )
						{
							if ( (vfilePhoto1.value) != "" )
							{
								vfilePhoto2.disabled = false;
							}
							else
							{
								vfilePhoto2.disabled = true;
								vfilePhoto3.disabled = true;
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 3 )
						{
							if ( (vfilePhoto2.value) != "" )
							{
								vfilePhoto3.disabled = false;
							}
							else
							{
								vfilePhoto3.disabled = true;
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 4 )
						{
							if ( (vfilePhoto3.value) != "" )
							{
								vfilePhoto4.disabled = false;
							}
							else
							{
								vfilePhoto4.disabled = true;
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 5 )
						{
							if ( (vfilePhoto4.value) != "" )
							{
								vfilePhoto5.disabled = false;
							}
							else
							{
								vfilePhoto5.disabled = true;
								vfilePhoto6.disabled = true;
							}
						}
						else if( intPhotoNo == 6 )
						{
							if ( (vfilePhoto5.value) != "" )
							{
								vfilePhoto6.disabled = false;
							}
							else
							{
								vfilePhoto6.disabled = true;
							}
						}
					}
					catch( ex )
					{
						alert( ex.message );
					}
				}
*/				
function CheckFilledImages()
{
	try
	{
		        
		var strErrMsg;
		strErrMsg = "";
		
		// Get Controls by ID
		//GetControlsByID();
			var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5, vfilePhoto6;
			vfilePhoto1 = document.getElementById( "ImgCarPhoto" );
			vfilePhoto2 = document.getElementById( "ImgCarPhoto2" );
			vfilePhoto3 = document.getElementById( "ImgCarPhoto3" );
			vfilePhoto4 = document.getElementById( "ImgCarPhoto4" );
			vfilePhoto5 = document.getElementById( "ImgCarPhoto5" );
			vfilePhoto6 = document.getElementById( "ImgCarPhoto6" );
	
		 if ((vfilePhoto6.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == "") ||
                ((vfilePhoto3.src) == "") ||
                ((vfilePhoto4.src) == "") ||
                ((vfilePhoto5.src) == "")) 
                {
      
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }		
		 } 
                
		 if ((vfilePhoto5.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == "") ||
                ((vfilePhoto3.src) == "") ||
                ((vfilePhoto4.src) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
               
         if ((vfilePhoto4.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == "") ||
                ((vfilePhoto3.src) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		 
		 if ((vfilePhoto3.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == ""))
                
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		    
		  if ((vfilePhoto2.src) != "")
		 {
		 if (((vfilePhoto1.src) == ""))
                              
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		
		//if( strErrMsg != "" )
		//{
			//alert( strErrMsg );
			//return false;
		//}
		
		return true;
	}
	catch( ex )
	{
		alert( ex.message );
	}
}

function CheckFilledImagesDownloads()
{
	try
	{
		        
		var strErrMsg;
		strErrMsg = "";
		
		// Get Controls by ID
		//GetControlsByID();
			var vfilePhoto1, vfilePhoto2, vfilePhoto3, vfilePhoto4, vfilePhoto5;
			vfilePhoto1 = document.getElementById( "ImgCarPhoto" );
			vfilePhoto2 = document.getElementById( "ImgCarPhoto2" );
			vfilePhoto3 = document.getElementById( "ImgCarPhoto3" );
			vfilePhoto4 = document.getElementById( "ImgCarPhoto4" );
			vfilePhoto5 = document.getElementById( "ImgCarPhoto5" );
			//vfilePhoto6 = document.getElementById( "ImgCarPhoto6" );
	
		  
                
		 if ((vfilePhoto5.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == "") ||
                ((vfilePhoto3.src) == "") ||
                ((vfilePhoto4.src) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
               
         if ((vfilePhoto4.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == "") ||
                ((vfilePhoto3.src) == ""))
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		 
		 if ((vfilePhoto3.src) != "")
		 {
		 if (((vfilePhoto1.src) == "") ||
                ((vfilePhoto2.src) == ""))
                
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		    
		  if ((vfilePhoto2.src) != "")
		 {
		 if (((vfilePhoto1.src) == ""))
                              
                {
                //strErrMsg += "Please upload the car photos in order\n";
                alert("Please upload the car photos in order\n");
				return false;
                }
		 } 
		
		//if( strErrMsg != "" )
		//{
			//alert( strErrMsg );
			//return false;
		//}
		
		return true;
	}
	catch( ex )
	{
		alert( ex.message );
	}
}

function OnMouseOverHomePoll( vControl )
{
	try
	{
		vControl.style.cursor = 'hand';
		vControl.className = "PollLink_Over";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OnMouseOutHomePoll( vControl )
{
	try
	{
		vControl.className = "PollLink_Out";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

var vPollID

function OpenPollInSameWindow( vTargetPage )
{
	try
	{
	
		vPollID = document.getElementById( "hhidPollID" ).value;
		
		// Get the Applcation Path Hidden Field
		GetApplicationPath();
	
		// Open the Page
		window.location = vhidApplicationPath.value + vTargetPage + "?PollID=" + vPollID;
	
	}
	catch( ex )
	{}
}

function OnMouseOverFeaturedCar( vControl )
{
	var Control
	Control = document.getElementById( vControl );
	try
	{
	
		
		Control.style.cursor = 'hand';
		//vControl.className = "MnuText_Over";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}


function OnMouseOutFeaturedCar( vControl )
{
	var Control
	Control = document.getElementById( vControl );
	try
	{
		vControl.className = "PollLink_Out";
	}
	catch( ex )
	{
		alert( 'OnMouseOver : ' + ex.message )
	}
}

function OpenTellAFriend(varSource, CarID, PhotoPath)
{

	try
	{
	
		var strCarID = CarID;
		var vPhotoPath =document.getElementById( PhotoPath );
		var vPhotoPathSrc;
		if (vPhotoPath == null)
		{
			vPhotoPathSrc = "";
		}
		else
		{
			vPhotoPathSrc = vPhotoPath.src;
		} 
		var strQueryString = "intCarID=" + strCarID + "&strPhotoPath=" + vPhotoPathSrc;
		//var vOptions = "dialogHeight: 300px;dialogWidth: 550px; edge: Raised; center: Yes; help: No; resizable: no; status: No;";
		var vOptions = "height=300,width=550,status=yes,toolbar=yes,menubar=no,location=no,scrollbars=yes";
		var strAppPath = document.getElementById( "__hhidApplicationPath" ).value;
		if(varSource == "Arabic")
		{
		//var retValue = window.showModalDialog( strAppPath + '/Arabic/TellAFriend.aspx?' + strQueryString  , document , vOptions );
		var retValue = window.open( strAppPath + '/Arabic/TellAFriend.aspx?' + strQueryString, null, vOptions );
		}
		else
		{
		//var retValue = window.showModalDialog( strAppPath + '/TellAFriend.aspx?' + strQueryString  , document , vOptions );
		var retValue = window.open( strAppPath + '/TellAFriend.aspx?' + strQueryString, null, vOptions );
		}
		
	
	}
	catch( ex )
	{}
}

function FillModelDDL(BrandControl,BrandID)
{

	try
	{
		var vBrandControl = document.getElementById(BrandControl);
		BrandID = vBrandControl.selectedValue; 
	}
	catch( ex )
	{
	}
}

function OpenPageInFrame( vTarget, vFrame )
{
	GetApplicationPath();
	var Frame = document.getElementById(vFrame);
	Frame.src = vhidApplicationPath.value + vTarget;
	//window.frameElement.parentElement.children(1).src = vhidApplicationPath.value + vTarget;
}

function OpenPageInNewWindow(varSource, QueryString, Res)
{

	try
	{
		var strQueryString = "";
		strQueryString = strQueryString + QueryString;
		
		if(Res==1)
		{
			var vOptions = "dialogHeight: 600px;dialogWidth:800px; edge: Raised; center: Yes; help: No; resizable: No; status: No";
		}
		else if(Res==2)
		{
			var vOptions = "dialogHeight: 768px;dialogWidth: 1024px; edge: Raised; center: Yes; help: No; resizable: No; status: No";
		}
		else if(Res==3)
		{
			var vOptions = "dialogHeight: 1024px;dialogWidth: 1280px; edge: Raised; center: Yes; help: No; resizable: No; status: No";
		}
		else if(Res==4)
		{
			var vOptions = "dialogHeight: 1200px;dialogWidth: 1600px; edge: Raised; center: Yes; help: No; resizable: No; status: No";
		}
		
		var strAppPath = document.getElementById( "__hhidApplicationPath" ).value;
		if(varSource == "Arabic")
		{
		var retValue = window.showModalDialog( strAppPath + '/Arabic/FullSizePhoto.aspx?' + strQueryString  , document , vOptions );
		}
		else
		{
		var retValue = window.showModalDialog( strAppPath + '/FullSizePhoto.aspx?' + strQueryString  , document , vOptions );
		}
		
	
	}
	catch( ex )
	{}
}


