function OpenWin(sFileName) {
		ww = screen.width;
        hh = screen.height;
		wwidth = ww-8;
		 wheight = hh-80;
		 top_ = 0;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
         options ='location=yes, toolbar=yes, status=yes, left=0, top=0, menubar=yes, height='+wheight+', width='+wwidth+', scrollbars = yes';
         file =sFileName;
         window.open(file,'picview',options);		
        }	

function OpenSaleWindow(sFileName,wwidth,wheight,winname,sScrollbars,iTop) {
        // open window
		var topvalue = 0;
		
		if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5) 
			sScrollbars="yes";
		else 
			sScrollbars = "no";
		if(winname == "") 
			winname = "defaultwindowname";
		 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
		 if(iTop == "" || arguments.length < 6)   
		 	topvalue = yy;			
		 else
		 	topvalue = iTop;
         options ='location=no, toolbar=no, status=no, left='+xx+', top='+topvalue+', menubar=no, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);		
        }	

var mouseOverDiv=false;
function toggleSale(divId)
{
   if(!mouseOverDiv){
	var myDiv=document.getElementById("div_"+divId);
	var myImage=document.getElementById("img_sale_"+divId);
	myDiv.style.left=myImage.style.left;
	(myDiv.style.display == 'none')? myDiv.style.display = 'block': myDiv.style.display = 'none';
   }
}
function toggleTr(TrId)
{
        var myTr=document.getElementById("tr_"+TrId);
      //  (myTr.style.display == 'none')? myTr.style.display = 'block': myTr.style.display = 'none';
		if (myTr.style.display == 'none'){ myTr.style.display = 'block';
		url="stat_update_click.php?dealer_id="+TrId;
		xmlhttpGet(url);
		} else {myTr.style.display = 'none';}
}

function set_submit(cat_id)
{
	document.listform.cat_id.value = cat_id;
	document.listform.submit();
}
function xmlhttpGet(strURL, objName) {
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
    self.xmlHttpReq.open('GET', strURL, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    self.xmlHttpReq.onreadystatechange = function() {
        if (self.xmlHttpReq.readyState == 4) {	// end of processing
        }
    }
    self.xmlHttpReq.send(strURL);
}
function MyOpenWindow(sFileName,wwidth,wheight,winname,sScrollbars,iTop)
{
        // open window
                var topvalue = 0;

                if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5)
                        sScrollbars="yes";
                else
                        sScrollbars = "no";
                if(winname == "")
                        winname = "defaultwindowname";
                 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
                 if(iTop == "" || arguments.length < 6)
                        topvalue = yy;
                 else
                        topvalue = iTop;
         options ='location=no, toolbar=no, status=no, left='+xx+',top='+topvalue+', menubar=no, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);
}
function OpenWindow(sFileName,wwidth,wheight,winname,sScrollbars,iTop) {
        // open window
                var topvalue = 0;

                if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5)
                        sScrollbars="yes";
                else
                        sScrollbars = "no";
                if(winname == "")
                        winname = "defaultwindowname";

                 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
                 if(iTop == "" || arguments.length < 6)
                        topvalue = yy;
                 else
                        topvalue = iTop;
         options ='location=no, toolbar=no,resizable=yes, status=no, left='+xx+', top='+topvalue+', menubar=no, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);
        }
function OpenWinsale(sFileName,wwidth,wheight,winname,sScrollbars,iTop) {
        // open window
                var topvalue = 0;

                if(sScrollbars=="" || sScrollbars=="yes" || sScrollbars=="1" || arguments.length<5)
                        sScrollbars="yes";
                else
                        sScrollbars = "no";
                if(winname == "")
                        winname = "defaultwindowname";

                 ww = screen.width;
         hh = screen.height;
         if(wwidth > ww) {xx=0;} else {xx=Math.round((ww-wwidth)/2)-5;};
         if(wheight > hh) {yy=0;} else {yy=Math.round((hh-wheight)/2);};
                 if(iTop == "" || arguments.length < 6)
                        topvalue = yy;
                 else
                        topvalue = iTop;
         options ='location=yes, toolbar=yes,resizable=yes, status=yes, left='+xx+', top='+topvalue+', menubar=yes, height='+wheight+', width='+wwidth+', scrollbars = '+sScrollbars+'';
         file =sFileName;
         window.open(file,winname,options);
        }
function cal(objname,cur_date,s_hotel_id) 
{
	error=false;
	if (objname=='end_date')
	{
		//alert($('#start_date').val());
		if( ($('#start_date').val()=='undefined') || ($('#start_date').val()=='בחר/י תאריך')) // here a date format check should be made -- dev
		{
			error=true;
			alert('יש לבחור מועד הגעה ולאחר מכן מועד עזיבה');
		}
	
	}
	if (objname=='start_date') // clear end date if new start date is chosen
	{
	
		
		$('#end_date').val('בחר/י תאריך');
		  
	
	}
	
	
	if (!error)
	{
			start_date = document.order.start_date.value;
			to_date = '';OpenWindow('../gulliver/calendar.php?s_hotel_id='+s_hotel_id+'&cur_date='+cur_date+'&objname='+objname+'&start_date='+start_date+'&to_date='+to_date,200,190,'Calendar','no');
	}
	
}
//$('#start_date').change(function(){alert('x')})

$('#num_of_rooms').change(function()
	{
		$('#search_target_div').hide('slow');

		$('#search_target_div').html('');
		//alert($('#num_of_rooms').val());
		rooms_to_show = $('#num_of_rooms').val();
		for (i=0;i<5;++i)
		{
			if (i<rooms_to_show)
			{
				$('#room'+i).show('slow');
			}
			else
			{
				$('#room'+i).hide('slow');
			}
		}		
	}
)



function setVal(val)
{
	document.getElementById('dateValDiv').value=val;
	
}

