//***************************************************************//
// Filename: JSFunctions.js
// Written By: Yasir Zaka Bhatti
// Creation Date: June 8th, 2005
//***************************************************************//

function callpage(url)
{
window.location.href=url;
}
function submit_form(myfield) {
	document.profile.savedate.value="no";
	document.profile.submit();
	return true;
}

function submitpage(mypage) {
	document.profile.action=mypage;
	document.profile.submit();
	return true;
}

function submit_search() {
	document.frmsearch.submit();
	return true;	
}


function submit_sale() {
	document.profile.submit();
	return true;	
}

function addnew(myfield) {
	//alert(myfield);
	document.profile.savedate.value=myfield;
	document.profile.submit();
	return true;
}

function caravans_rental(str) {
	alert("abc");
	return true;
	//alert(document.caravans_rental.rental_county_id.value);
	//document.caravans_rental.action = "caravans_rental_areas.php?caravan_county_id="+document.caravans_rental.rental_county_id.value;
	//document.caravans_rental.submit();
}

function caravan_div(str) { 
	var str;
	//alert("Hello");
	str = document.getElementById("caravan_type").value;
	
	if (str == "Static") {
		document.getElementById("static_caravan").style.visibility = "visible";
		document.getElementById("tourer_caravan").style.visibility = "hidden";
		document.getElementById("motorhome_caravan").style.visibility = "hidden";
		
		document.getElementById("static_caravan_row1").style.visibility = "visible";
		document.getElementById("static_caravan_row2").style.visibility = "visible";
		document.getElementById("tourer_caravan_row1").style.visibility = "hidden";
		document.getElementById("tourer_caravan_row2").style.visibility = "hidden";
		document.getElementById("motorhome_caravan_row1").style.visibility = "hidden";
		document.getElementById("motorhome_caravan_row2").style.visibility = "hidden";		
		
	} else {
		if (str == "Tourer") {
			document.getElementById("static_caravan").style.visibility = "hidden";
			document.getElementById("tourer_caravan").style.visibility = "visible";
			document.getElementById("motorhome_caravan").style.visibility = "hidden";

			document.getElementById("static_caravan_row1").style.visibility = "hidden";
			document.getElementById("static_caravan_row2").style.visibility = "hidden";
			document.getElementById("tourer_caravan_row1").style.visibility = "visible";
			document.getElementById("tourer_caravan_row2").style.visibility = "visible";
			document.getElementById("motorhome_caravan_row1").style.visibility = "hidden";
			document.getElementById("motorhome_caravan_row2").style.visibility = "hidden";
		} else {
			document.getElementById("static_caravan").style.visibility = "hidden";
			document.getElementById("tourer_caravan").style.visibility = "hidden";
			document.getElementById("motorhome_caravan").style.visibility = "visible";
			
			document.getElementById("static_caravan_row1").style.visibility = "hidden";
			document.getElementById("static_caravan_row2").style.visibility = "hidden";
			document.getElementById("tourer_caravan_row1").style.visibility = "hidden";
			document.getElementById("tourer_caravan_row2").style.visibility = "hidden";
			document.getElementById("motorhome_caravan_row1").style.visibility = "visible";
			document.getElementById("motorhome_caravan_row2").style.visibility = "visible";
		}
	}
	return true;
}

function SelectAllMakeOnline() { 
	//alert(document.makeonline.ChkLive[0].checked);
	/*alert(document.makeonline.selectall.checked);*/
	if (document.makeonline.selectall.checked == true) {
		val = true;
	} else {
		val = false;
	}
	if (document.makeonline.caravancount.value > 1) {	// Error was comming if only one email thats why this check
		for (var i=0; i<document.makeonline.caravancount.value; i++) {
			//alert(i);
			document.makeonline.ChkLive[i].checked=val;
		}
	}
}


function MonthsGlobal() { 
	for (var i=0; i<document.makeonline.caravancount.value; i++) {
		document.makeonline.caravan_duration[i].value=document.makeonline.globalmonths.value;
	}
}


function showimage(nama) { 
	document.getElementById(nama.id).className = "athumbnail";
}

function hideimage(nama) { 
	document.getElementById(nama.id).className = "thumbnail";
}


function printit() {
	window.print();
}

function ShowHideMap(myid) {

  if (document.getElementById("googlemap").style.display == "none") {
    document.getElementById("googlemap").style.display = "block";
	document.getElementById(myid.id).innerHTML='<a href="#">Hide Map</a>';
	/*document.getElementById("part").style.display = "none";*/
  } else {
    document.getElementById("googlemap").style.display = "none";
	document.getElementById(myid.id).innerHTML='<a href="#">Show Map</a>';	
	/*document.getElementById("part").style.display = "block";*/
  }
}
function ShowHide(myid , display) {
  	
    document.getElementById(myid).style.display = display;
  
  if (myid == 'contactdiv')
 	  { 
	    ShowHide('dimdiv',display);
		document.getElementById(myid).style.top = 30+getScrollXY()+'px';
		//alert(document.body.clientHeight);
		document.getElementById('dimdiv').style.height = document.body.clientHeight+'px';
		
	  }
}
function PopUpImage(display, imagepath){

	document.getElementById('floatdiv').style.display = display;
	document.getElementById('floatdiv').style.top = 30+getScrollXY()+'px';
	document.getElementById('largeImage').src = imagepath;
}
function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return  scrOfY ;
}

function WindowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return myHeight ;
 // window.alert( 'Width = ' + myWidth );
 // window.alert( 'Height = ' + myHeight );
}


function show_photo(photoname, type, width, height) {
	//alert("hello");
	mywindow = window.open('/caravanphoto.php?p='+photoname+'&t='+type,'winList','height='+height+',width='+width+',scrollbars=no,resizable=yes');
	//mywindow = window.open('actualsizephoto.php?id='+photoname,'winList','height=700,width=520,scrollbars=yes,resizable=yes');	
	mywindow.focus();
	return true;
}