
/********** DROP DOWN MENU **************************************/

var timeout         = 500;
var closetimer		= 0;
var ddmenuitem      = 0;

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   
function showform2(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;
	if(iState==1)	{
  	 obj.visibility = "visible";
  	 					}
else					{
  	 obj.visibility = "hidden";	
						}  	 					
}


function showform(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;
	
  	 obj.visibility = document.layers ? (iState ? "show" : "hide") :
   	(iState ? "visible" : "hidden");
}



function showDisplay(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;

  	 obj.display= document.layers ? (iState ? "block" : "none") :
   	(iState ? "block" : "none");
}



	function showNewColor(targetid, status) {

		// setup vars



		var correctColor = "#ECF6FF";

		var elseColor = "#FAC9B8";

		

		if((document.getElementById)&& (document.getElementById(targetid)!=null)) {

	  		// Get a reference to the element

			var myElement = document.getElementById(targetid);



			// Check the element's style object and background property are available

		 	if (myElement.style) {

    			// Check the value of the property

			    if(status == 'correct'){

					// change style to new color

					document.getElementById(targetid).style.backgroundColor = correctColor;

				}else {


					document.getElementById(targetid).style.backgroundColor = elseColor;      

    			}

  			}else {	



				return;

  			}

		}else {

		  return;

		}

	}


function jsddm_open()
{	jsddm_canceltimer();
	jsddm_close();
	ddmenuitem = $(this).find('ul').eq(0).css('visibility', 'visible');}

function jsddm_close()
{	if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{	closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{	if(closetimer)
	{	window.clearTimeout(closetimer);
		closetimer = null;}}


/********** GET ELEMENT BY CLASS NAME **************************************/	
		
function getElementsByClass( searchClass, domNode, tagName) { 
	if (domNode == null) domNode = document;
	if (tagName == null) tagName = '*';
	var el = new Array();
	var tags = domNode.getElementsByTagName(tagName);
	var tcl = " "+searchClass+" ";
	for(i=0,j=0; i<tags.length; i++) { 
		var test = " " + tags[i].className + " ";
		if (test.indexOf(tcl) != -1) 
			el[j++] = tags[i];
	} 
	return el;
} 

function showtab(tabname) 
{ 
	// hide every element with class 'tab'  
	var tabs = getElementsByClass('tab');
	for(i=0; i<tabs.length; i++) 
		tabs[i].style.display = 'none';
	// hide every element with class 'tab'		 
 
	document.getElementById(tabname).style.display='block';
	// show element with given tabname 
} 

/********** CHECK WITH COOKIES **************************************/
function check(id_1){

	var c_1 = ReadCookie(id_1);if (c_1 == "valid"){hide_left_menu();}
}
/********** HIDE LEFT MENU **************************************/
function hide_left_menu(){
	document.getElementById('main_left_menu_shown').style.display='none';
	document.getElementById('main_left_menu_hidden').style.display='';
	document.getElementById('main_body').width='100%';
	SetCookie("hide_menu", "valid", 86400*7);
}
/********** SHOW LEFT MENU **************************************/
function show_left_menu(){
	document.getElementById('main_left_menu_shown').style.display='';
	document.getElementById('main_left_menu_hidden').style.display='none';
	document.getElementById('main_body').width='80%';
	SetCookie("hide_menu", "", -86400*7);
}
/********** SET COOKIE **************************************/
function SetCookie() {

	if(arguments.length < 2) { return; }
	var n = arguments[0];
	var v = arguments[1];
	var d = 0;
	if(arguments.length > 2) { d = parseInt(arguments[2]); }
	var exp = '';
	if(d > 0){
		var now = new Date();
		then = now.getTime() + (d * 24 * 60 * 60 * 1000);
		now.setTime(then);
		exp = '; expires=' + now.toGMTString();
	}
	document.cookie = n + "=" + escape(String(v)) + '; path=/' + exp;

}
/********** READ COOKIE **************************************/
function ReadCookie(n) {
var cookiecontent = new String();
if(document.cookie.length > 0) {
	var cookiename = n+ '=';
	var cookiebegin = document.cookie.indexOf(cookiename);
	var cookieend = 0;
	if(cookiebegin > -1) {
		cookiebegin += cookiename.length;
		cookieend = document.cookie.indexOf(";",cookiebegin);
		if(cookieend < cookiebegin) { cookieend = document.cookie.length; }
		cookiecontent = document.cookie.substring(cookiebegin,cookieend);
		}
	}
return unescape(cookiecontent);
}
/********** NEW JS FUNCTIONS **************************************/

//check needed fields function
function check_needed_fields(and_fields_id,or_fields_id,form_name){
	
	// check 'and' fields values
	if (and_fields_id){
		
		var splited_fields_id = and_fields_id.split(",");
		var fields_cnt = splited_fields_id.length;
		var chkd_fields_array = new Array();
		
		for (var f=0;f<fields_cnt;f++){
			var chkd_field_id = splited_fields_id[f];
			var chkd_field_val = document.getElementById(chkd_field_id).value;
			if (chkd_field_val){
				chkd_fields_array[f] = chkd_field_val;
			}
		}
		
		if(chkd_fields_array.length != splited_fields_id.length)
			var and_fields_flag = false;
		else
			var and_fields_flag = true;
		
	}else{
		var and_fields_flag = true;
	}
	
	
	// check 'or' fields values
	if (or_fields_id){
	
		var splited_fields_id = or_fields_id.split(",");
		var fields_cnt = splited_fields_id.length;
		var chkd_fields_array = new Array();
		
		for (var f=0;f<fields_cnt;f++){
			var chkd_field_id = splited_fields_id[f];
			var chkd_field_val = document.getElementById(chkd_field_id).value;
			if (chkd_field_val){
				chkd_fields_array[f] = chkd_field_val;
			}
		}
		
		if(chkd_fields_array.length >= 1)
			var or_fields_flag = true;
		else
			var or_fields_flag = false;
	
	}else{
		var or_fields_flag = true;
	}
		
		if (or_fields_flag && and_fields_flag)
			document.forms[form_name].submit();
		else
			alert('Please Complete All Required Fields !');
}

//function close after seconds
function close_after_seconds(seconds){
	setTimeout(function() {
	window.close();
	}, seconds);
}
/*****************************************************************/

 function unMarkAllRows( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;

        }
    }

    return true;
}

 
 
  
  function markAllRows( container_id ) {

    var rows = document.getElementById(container_id).getElementsByTagName('tr');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
			
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                
            }
        }
    }

    return true;
}


function popitup(url, name, atributes) {
	newwindow=window.open(url,name, atributes);
	if (window.focus) {newwindow.focus()}
	return false;
}


function ajax_do_general (url) {

	var jsel = document.createElement('SCRIPT');
	jsel.type = 'text/javascript';
	jsel.src = url;

	// Append JS element (therefore executing the 'AJAX' call)
	document.body.appendChild (jsel);		
		
										}

function display(myimage) {
 html = "<HTML><HEAD><TITLE>Photo</TITLE>" +
  "</HEAD><BODY LEFTMARGIN=0 " 
  + "MARGINWIDTH=0 TOPMARGIN=0 MARGINHEIGHT=0><CENTER>" 
  + "<IMG SRC='" + myimage + "' BORDER=0 NAME=image " 
  + "onload='window.resizeTo(document.image.width,document.image.height)'>"
  + "</CENTER>" 
  + "</BODY></HTML>";
 popup=
 window.open
  ('','image',
  'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1');
 popup.document.open();
 popup.document.write(html);
 popup.document.focus();
 popup.document.close()
 }




 function unMarkAllRowsX( container_id ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;

        }
    }

    return true;
}

 
 
  
  function markAllRowsX( container_id ) {
  	
 	
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' ) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                
            }
        }
    }

    return true;
}


  function markAllRowsW( container_id, className ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' && checkbox.className==className) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                
            }
        }
    }

    return true;
}



function unMarkAllRowsW( container_id, className  ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' && checkbox.className==className) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;

        }
    }

    return true;
}

 
 
 
 function markAllRowsZ( container_id, className ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' && checkbox.id==className) {
            unique_id = checkbox.name + checkbox.value;
            if ( checkbox.disabled == false ) {
                checkbox.checked = true;
                
            }
        }
    }

    return true;
}



function unMarkAllRowsZ( container_id, className  ) {
    var rows = document.getElementById(container_id).getElementsByTagName('td');
    var unique_id;
    var checkbox;

    for ( var i = 0; i < rows.length; i++ ) {

        checkbox = rows[i].getElementsByTagName( 'input' )[0];

        if ( checkbox && checkbox.type == 'checkbox' && checkbox.id==className) {
            unique_id = checkbox.name + checkbox.value;
            checkbox.checked = false;

        }
    }

    return true;
}

  
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   
function showform2(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;
	if(iState==1)	{
  	 obj.visibility = "visible";
  	 					}
else					{
  	 obj.visibility = "hidden";	
						}  	 					
}


function showform(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;
	
  	 obj.visibility = document.layers ? (iState ? "show" : "hide") :
   	(iState ? "visible" : "hidden");
}



function showDisplay(item, iState) // 1 visible, 0 hidden
{
 	var obj = document.layers ? document.layers[item] :
	 document.getElementById ?  document.getElementById(item).style :
	document.all[item].style;

  	 obj.display= document.layers ? (iState ? "block" : "none") :
   	(iState ? "block" : "none");
}



	function showNewColor(targetid, status) {

		// setup vars



		var correctColor = "#ECF6FF";

		var elseColor = "#FAC9B8";

		

		if((document.getElementById)&& (document.getElementById(targetid)!=null)) {

	  		// Get a reference to the element

			var myElement = document.getElementById(targetid);



			// Check the element's style object and background property are available

		 	if (myElement.style) {

    			// Check the value of the property

			    if(status == 'correct'){

					// change style to new color

					document.getElementById(targetid).style.backgroundColor = correctColor;

				}else {


					document.getElementById(targetid).style.backgroundColor = elseColor;      

    			}

  			}else {	



				return;

  			}

		}else {

		  return;

		}

	}

function ShowWaiting() {
	document.getElementById('header').style.display = 'none';
	document.getElementById('Content-bg').style.display = 'none';
	document.getElementById('footer').style.display = 'none';

	document.getElementById('Waiting').style.display = 'block';
	document.HotelsReservationEngine.submit();	
	
											}
   

  
