
var dbgString = "";//global var for debuging 2 file in the system
var ns = false;
var ie = false;
var ff = false;
if (document.layers) ns = true;
if (document.all) ie = true;

if(document.getElementsByTagName("head")[0].textContent)
	ff = true

//*******************************************************************
//initilize java var for upper bar-only for home page used
var IsFlashMode=true;
//*******************************************************************
var xmlArr	 = "";
var responseContent			= null;
var responseMethod			= null;
var responseTimeout			= 0;
var getResponseXML			= true;

//Create Exceptions.
var errorObjectNotSupported	= 'The DOM object not supported by current browser.\n';
var errorServerStatusCode	= 'The server status code indicates that [somthing is wrong].\n';
var errorInitialezdDom		= 'The DOM XMLHTTP object failed to load.\n';

InitializeXMLHTTP();
function InitializeXMLHTTP()
{
	try
	{
		xmlArr = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(ex)
	{
		try
		{
			xmlArr = new ActiveXObject('Microsoft.XMLHTTP');
		}
		catch(ex)
		{
			try
			{
				xmlArr = new XMLHttpRequest();
			}
			catch (ex)
			{
				xmlArr = null;
				throw new Error(100, errorObjectNotSupported + 'Base Exception: ' + ex);
			}
		}
	}
}

//*******************************************************************
function processResponse()
{
	if (xmlArr.readyState == 4)
	{
		if (xmlArr.status == 200)
		{
			//Assign the response content from server as XML.
			if (getResponseXML)
				responseContent = xmlArr.responseXML;

			//Assign the response content from server as clear text.
			else
				responseContent = xmlArr.responseText;
		}
		else
		{
			throw new Error(101, errorServerStatusCode + ' Status Code Text: ' + xmlArr.statusText + '\nStatus Code: ' + xmlArr.status);
		}
	}
}

//*******************************************************************
function onChange(obj,sub,product)
{
  var url = "/site/getSubFolders.hx.asp?selectBy=" + product
	//window.open("/site/getSubFolders.hx.asp?selectBy=" + product);
    
  try{		
		if (xmlArr != null) {
		  //responseTimeout = 0;
			xmlArr.onreadystatechange = processResponse;//xml2options(xmlArr,sub);
			xmlArr.open('GET', url, false);
			xmlArr.send(null);
			
			xml2options(xmlArr,sub)
		}
	}catch (ex){
			alert('Base Exception: ' + ex.description);
			//throw new Error('Base Exception: ' + ex.description);
	}
}

//*******************************************************************
function   getAgencyName(obj,sub,product){
	
	try{
	if (xmlArr != null) {
	    var url ="/site/travelAgent/getSubFolders.hx.asp?selectBy=" + product;
	    
    	xmlArr.onreadystatechange = processResponse;//xml2options(xmlArr,sub);
		xmlArr.open('GET', url, false);
		xmlArr.send(null);
	    //window.open("/site/travelAgent/getSubFolders.hx.asp?selectBy=" + product)
	    xml2options(xmlArr,sub)
	}
	}catch(e){
	    alert(e.description)
	}
}

//*******************************************************************
function xml2options(xmlArr,sel)
{
    if (xmlArr)
		{
    	try
    	{
					var elems = xmlArr.responseXML.getElementsByTagName("ROW");
					
					//alert(elems.length)
					if(elems.length>0)
						sel.length=elems.length;
					else
						sel.length=elems.length+1;
					
					sel[0].selected=true;
					for (var i=0; i < elems.length; i++) {
						//e = elems.nextNode();
						sel[i].text=elems[i].getAttribute("name");
						sel[i].value=elems[i].getAttribute("id");

						if(1*elems[i].getAttribute("highlight")==1)
							sel[i].style.color = "#F19101"; //old value - "#FF9A00"; changed by German 16/01/2007
						else
							sel[i].style.color = "black";	
					}
			}
			catch(ex)
			{
				alert("xml2options error: " + ex.description)
			}
		}
}

////////////////////////////////////////////////////////
function round(number, X){
		 X = (!X ? 2 : X);
		return Math.round(number * Math.pow(10, X)) / Math.pow(10, X);
}

//*******************************************************************
function checkForFlash(){
    var FlashMode = 0;

    if ((navigator.appName == "Netscape" && navigator.plugins)){
        // Tests for Netscape Navigator (all versions)
        numPlugins = navigator.plugins.length;
        if (numPlugins > 0){
            for (i = 0; i < numPlugins; i++){
                plugin = navigator.plugins[i];
                numTypes = plugin.length;
                for (j = 0; j < numTypes; j++){
                    mimetype = plugin[j];
                    if (mimetype){
                        if (mimetype.enabledPlugin && (mimetype.suffixes.indexOf("swf") != -1))
                            FlashMode = 1;

                        if (navigator.mimeTypes["application/x-shockwave-flash"] == null)
                            FlashMode = 0;
                    }
                 }
             }
         }
     }

    if (FlashMode){
		IsFlashMode=true
    }
    else if (navigator.appName.indexOf("Microsoft") == -1){
        IsFlashMode=false
    }
}

//*******************************************************************
function changeLinkColor(obj,mouseOver) {
  if (ie) {
	  if (mouseOver)
	      obj.style.color = '#3B5D8A';//#ff7800';
	  else
	      obj.style.color = '';
	}
}

//*******************************************************************
function imgOnOff(img,on){
imgSrc=img.src
imgSrc = imgSrc.toLowerCase( )
	if(on){
		imageOn=imgSrc.substring(0,imgSrc.indexOf("off.gif")) + "on.gif"
		document.images[img.name].src =imageOn
	}
	else{
		imageOff=imgSrc.substring(0,imgSrc.indexOf("on.gif")) + "off.gif"
		document.images[img.name].src =imageOff
	}
}

//*******************************************************************
//these two functions are to change the bckground of the open div's 
var currentFontColor = "";

function NavRollOver(obj,bgColor,fontColor) {
	currentFontColor = obj.style.color;

	if(ie){obj.style.cursor='hand'}
	if(NavRollOver.arguments.length==1){
		bgColor = "" 
		fontColor = ""
	}
	else{
		if(NavRollOver.arguments.length==2){
			bgColor = bgColor 
			fontColor = ""
		}
		else{
			if(NavRollOver.arguments.length==3){
				bgColor = bgColor 
				fontColor = fontColor
			}
		}
	}		
	 obj.bgColor=bgColor;
	 obj.style.color = fontColor
	 //obj.link.style.color = fontColor
}
/*-------------------------------*/
//this function gets the color of the unique category to show
function NavRollOut(obj,bgColor,fontColor) {
	if(NavRollOut.arguments.length==1){
		bgColor	 = '' 
		fontColor = currentFontColor;
	}
	else{
		if(NavRollOut.arguments.length==2){
			bgColor	 = bgColor 
			fontColor = currentFontColor
		}
		else{
			if(NavRollOut.arguments.length==3){
				bgColor   = bgColor ;
				fontColor = fontColor;
			}
		}
	}		
	 obj.bgColor     = bgColor;
	 obj.style.color = fontColor
	 status = "Done"
}

//*******************************************************************
function checkForm(whatToCheck,theAction) {
	//check only the sended object in the form
	if (whatToCheck.value=="" || whatToCheck.value=="0") return false;
	window.location.href=theAction + "&" + whatToCheck.name + "=" + whatToCheck.value;
	return false;
}

//*******************************************************************
function checkMultiForm(theForm,theAction) {
	//check all the object in the sended form
	var qString = "";
	for (var i=0;i<theForm.length;i++){
		if(theForm[i].value != "" && theForm[i].value != "0"){
			qString += "&" + theForm[i].name + "=" + theForm[i].value;
		}
	}
	if (qString == "") return false;
	window.location.href=theAction + qString;
	return false;
}

//*******************************************************************
function validateEmail(obj) {
	var re;
	re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	if (!re.test(obj.email.value)){
		//seccessMessege('please enter a valid email',"Error Message",800,200);
		obj.email.focus();
		obj.email.select();
		return false
	}
	return true
} 

/**********************************************************/
function hidemenus(i){
	status = "Done"
	document.document.getElementById("divSubmenu"+i).style.visibility="hidden"
	if(barMenu.pageId == "14a")showElement("SELECT")
}

/**********************************************************/
function img_on_off(imgNum,on){
	if(on){
		document["i" + imgNum].src = imgBarPath 
			+ barMenu.menus[imgNum].imgOn.src.substring(barMenu.menus[imgNum].imgOn.src.lastIndexOf("/")+1);
	}
	else{
		if (barMenu.groupSN != barMenu.menus[imgNum].groupSN){
			document["i" + imgNum].src = imgBarPath 
				+ barMenu.menus[imgNum].imgOff.src.substring(barMenu.menus[imgNum].imgOff.src.lastIndexOf("/")+1);
		}
	}
}

/**********************************************************/
function goToAddress(address) {
	
	window.location.href=address
}

function openWindow(url,param,wName,height,width){
	var nHeight=350,nWidth=400;
	if(! isnull(height))nHeight = height
	if(! isnull(height))nWidth = width
	
	wName = nz(wName,"defWin1")
	if(isnull(param)) param = "scrollbars=no,toolbar=no,resizable=0,left=0,top=0,width="+nWidth+",height="+nHeight

	var win = window.open(url, wName ,param);
	win.focus();
}

function openPopUp(address,width,height) {
	if(isnull(width)) width=240
	if(isnull(height)) height=320
	
	if(address!=null)	{
		window.open(address,'','scrollbars=no,toolbar=no,resizable=0,top=10,left=10,height='+height+',width='+width+'')
		
	}	
}
//*******************************************************************
function showHideDiv(obj,cancelBubble){
	if (cancelBubble) window.event.cancelBubble = true;
	if (obj.style.display == "none"){
		obj.style.display = "";
	}
	else{
		obj.style.display = "none";
	}
}

function showDiv(obj){
	if (obj.style.display == "none"){
		obj.style.display = "";
	}
}

//*******************************************************************
function showHideDiv2(div,cancelBubble,stam){
	//get a literal name of the div-not object like the regular 'showHideDiv' func
	if (cancelBubble) window.event.cancelBubble = true;
	var oDiv = document.getElementById(div)
	if(isnull(oDiv)) return;
	if (oDiv.style.display == "none"){
		oDiv.style.display = "";
	}
	else{
		oDiv.style.display = "none";
	}
}

//*******************************************************************
function divOnOff(div,cancelBubble,on){
	if (cancelBubble) window.event.cancelBubble = true;
	var oDiv = document.getElementById(div)
	if(isnull(oDiv)) return;
	if(on){
		oDiv.style.display = "";
		//alert(oDiv.id)
	}
	else{
		status = "Done"
		oDiv.style.display = "none";
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////
// Tests whether the given argument is empty or null
function isnull(arg) {
	arg = arg+'';
	return (arg == '' || arg == 'null' || arg == 'undefined');
}

///////////////////////////////////////////////////////////////////////////////////////////////////
function iif(q,truePart,falsePart){
	//the clasic iif of vb
	return (q) ? truePart : falsePart;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
function nz(param,val){
	//if the param is null or 0 return val or "" if val not sopplied
	return(
		isnull(param)
		? ((!isnull(val)) ? val : "") 
		: param
	)
}
///////////////////////////////////////////////////////////////////////////////////////////////////
function checkEmail(email){
	var atPos = email.indexOf("@",1)
	var invalidChars = " /:;,"
	if(isnull(email)){ //email cannot be empty
		forum.item("txtEmail").focus()
		return("אנא הזן ערך בשדה דואר אלקטרוני.");
	}
	
	for(var i=0; i<invalidChars.length; i++){
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar,0) != -1){ //email cannot be invalid chars
			return ("קיים תו בלתי חוקי בתוך כתובת הדואר שלך");
		}
	}
	if((email.indexOf("@")) != (email.lastIndexOf("@"))){ //email must be one "@" symbol
		return("כתובת דואר האלקטרוני שלך מכיל יותר מ@ אחד.");
	}
	
	if(email.indexOf("@") == -1){ //check if there is "@" symbol in the email
		return("כתובת דואר אלקטרוני שלך שגוייה אנא הוסך @")
	}
	
	if((email.indexOf("@")) == 0){ //check if the "@" symbol is in the first place
		return("כתובת דואר שלך שגוייה הנקודה נמצאת במקום בלתי חוקי.");
	}
	
	if((email.indexOf(".")) == -1){ //check if there is "." symbol in the email
		return("כתובת דואר האלקטרוני שלך שגוייה אנא הוסף נקודה.")
	}
	
	if((email.indexOf(".")) < atPos){ // check if the "." before the "@" symbol
		return("הנקודה נמצאת במקום בלתי חוקי בכתובת דואר אלקטרוני שלך.");
	}
	
	if((email.indexOf(".")) == atPos+1){ // check if the "." before the "@" symbol
		return("הנקודה נמצאת במקום בלתי חוקי בכתובת דואר אלקטרוני שלך.");
	}
	
	if(email.lastIndexOf(".") == (email.length -1)){ //check if the "." is the last in the email
		return("כתובת דואר האלקטרוני שלך שגוייה אנא הזן ערך לאחר הנקודה");
	}
	
	var dotCount = 0;
	for(var j=0; j<email.length; j++){
		if(email.substring(j,j+1) == ".") dotCount ++ // check if there isn't more then two dots
		if (dotCount  >2)	{
			return("כתובת הדואר האלקטרוני שלך שגוייה היא יכולה להכיל עד שני נקודות");
		}
	}
	
	if(email.indexOf("..") != -1){ // check if the isn't two dots in 
		return("כתובת הדואר אלקטרוני שלך שגוייה אין להזין שתי נקודות ברצף");
	}

	return true;
	
}
///////////////////////////////////////////////////////////////////////////////////
//check for vertical scroll bars
function hasVScroll(){
	return(screen.availHeight < document.body.scrollHeight)
}

///////////////////////////////////////////////////////////////////////////////////
//check the search form if is null - if not submit the search
function submitSearch(){
	if(isnull(frmSearch.item("searchText").value)) return;
	var searchPI = barMenu.dir == "RTL" ? 170 : 270;
	goToAddress("wingate.asp" + "?pi=" + searchPI + "&search=" + frmSearch.item("searchText").value);
}

function hideElement(elmID,num)
{
	for (i = 0; i < num; i++)
	
		document.all.tags(elmID)[i].style.visibility = "hidden";
	
}	

function showElement(elmID)
{
	for (i = 0; i < document.all.tags(elmID).length  ; i++)
	document.all.tags(elmID)[i].style.visibility = "";
}
function openLink(address) {

	if(address!=null)	window.open(address)
	return 
}
function getDate(source,toDay,x,color, oObj)
{
	if (window.showModalDialog)
	{
		value	=	showModalDialog('/site/calander.asp?thisDay="' + toDay +'"&color='+color+'','Dialog Arguments Value','dialogHeight: 230px; dialogWidth: 275px; scroll:0')
		UpdateDate(source,value)
	}
	else
	{
		thisDay = toDay;
		UpdateCalendarDiv(source, toDay, color, oObj)
		//value	=	openWindow('/site/calander.asp?thisDay="' + toDay +'"&color='+color+'', 'width=275,height=230,top=300,left=300,scrollbars=no,toolbar=no,resizable=yes,modal=yes', 'Dialog Arguments Value', 230, 275)
	}
}
/////////////////////////////////////
function UpdateDate(source,value,x)
{	
	if (isnull(value)){return}
	var day = value.substring(0,value.indexOf(",")) 
	num = value.indexOf(",")+1
	value = value.substring(num,value.length)
	var month=value.substring(0,value.indexOf(",")) 
	num = value.indexOf(",")+1
	value = value.substring(num,value.length)
	if(source == 'pick'){
		switch(nz(x)+""){
			case "2" :
				document.all.form1.pickday_2.value=day;
				document.all.form1.pickmonth_2.value=month;
				document.all.form1.pickyear_2.value=value;
				break
			case "3" :
				document.all.form1.pickday_3.value=day;
				document.all.form1.pickmonth_3.value=month;
				document.all.form1.pickyear_3.value=value;
				break
			default :
				document.all.form1.pickday.value=day;
				document.all.form1.pickmonth.value=month;
				document.all.form1.pickyear.value=value;
				break			
		}
	}
	else if(source == 'off'){
		switch(x+""){
			case "2" :
				document.all.form1.offday_2.value=day;
				document.all.form1.offmonth_2.value=month;
				document.all.form1.offyear_2.value=value;
				break
			case "3" :
				document.all.form1.offday_3.value=day;
				document.all.form1.offmonth_3.value=month;
				document.all.form1.offyear_3.value=value;
				break
			default :
				document.all.form1.offday.value=day;
				document.all.form1.offmonth.value=month;
				document.all.form1.offyear.value=value;
				break			
		}
	}
}

/////////////////////////////////////////////////////////////////////////////////////////
	// cleans the <![CDATA[]]> tags from a string .
	
		function cleanCData(str){
			if(str.indexOf("<![CDATA[")==0){
					return (str.substring(9,str.length-9-3).replace(/<\/TBODY>/g,"").replace(/<TBODY>/g,""));
				}
					return str.replace(/<\/TBODY>/g,"").replace(/<TBODY>/g,"");
			}	
			
		

/////////////////////////////////////////////////////////////////////////////////////////
function cleanCDataXML(str){
	return str.replace(/^<\!\[CDATA\[/,'').replace(/\]\]>$/,'')
		
}

//////////////////////////////////////////////////////////////
function seccessMessegeMouseClick(msg,title,top,left){
	
	try{hideObj(document.all.orderDiv);
	}catch(e){}
		try{hideObj(document.all.contactDiv);
	}catch(e){}
	
	document.getElementById('seccessMessege').innerHTML=msg;
	document.getElementById('messageTitle').innerHTML=title;
	document.getElementById('seccess').style.display="";
		
	if (top==null){
		messageTitle
		document.getElementById('seccess').style.top=window.screen.height/2-document.getElementById('seccess').offsetHeight/2;
		document.getElementById('seccess').style.left=window.screen.availWidth/2-document.getElementById('seccess').offsetWidth/2
		window.focus();
	}else{
		document.getElementById('seccess').style.top= event.clientX-top;
		document.getElementById('seccess').style.left=left;
		window.focus();
	}	
}

//////////////////////////////////////////////////////////////
function seccessMessege(msg,title,s_top,s_left,noTop){
	try{hideObj(document.all.orderDiv);
	}catch(e){}
		try{hideObj(document.all.contactDiv);
	}catch(e){}
	
	document.getElementById('seccessMessege').innerHTML=msg;
	//document.getElementById('seccessMessege').style.font-family="verdana"
	document.getElementById('messageTitle').innerHTML=title;
	document.getElementById('seccess').style.display="";
	
	var new_top		= ((s_top=="")||(!s_top)) ? 125 : s_top;
	var new_left	= ((s_left=="")||(!s_left)) ? 310 : s_left;
	
	if(window.screen.availWidth == 800 && (new_top > 125 || new_left > 310)){
		if(noTop ==1){
			document.getElementById('seccess').style.top=600;
			document.getElementById('seccess').style.left=250;
		}
		else if(noTop ==2){
			document.getElementById('seccess').style.top=800;
			document.getElementById('seccess').style.left=250;
		}
		else{
			if(new_top > 125 || new_top < 100){
				document.getElementById('seccess').style.top=200;
			}
			if(new_left > 310 || new_left< 100){
				document.getElementById('seccess').style.left=250;
			}
		}
	}
	else{
		document.getElementById('seccess').style.top=new_top;
		document.getElementById('seccess').style.left=new_left;
	}
	
	window.focus();
}
/////////////////////////////////////////////////////////////
function closeSeccess(){
	try{showObj(document.all.contactDiv);
	}catch(e){}
	document.getElementById('seccess').style.display="none";
	document.getElementById('seccessMessege').innerHTML="";
	document.getElementById('seccess').style.top=0;
	document.getElementById('seccess').style.left=0;
}

//////////////////////Form Vaildation///////////////////////////

function chackcancel(theForm){
	
if(theForm.resnum.value == ""){
	seccessMessege("Please enter reservation Number","Warning Message",150,600)
	theForm.resnum.focus();
	return
	}
			
if ((theForm.resnum.value.charAt(0) != 4 || theForm.resnum.value.charAt(0) != 5) && theForm.resnum.value.length != 6){
	seccessMessege("Your Reservation Number NOT Correct","Warning Message",150,600)
	theForm.resnum.focus();
}
		
		
if(theForm.countryO.value == 0){
	seccessMessege("Please choose country","Warning Message",150,600)
	theForm.countryO.focus();
	return
	}

theForm.pick_up_dateO.value  = theForm.pickyearC.value+"-"+theForm.pickmonthC.value+"-"+theForm.pickdayC.value
theForm.submit()

}

function findOrder(){
var areaXml;
	try{
    	if (window.ActiveXObject)
		{
		    var xmlObjectA=new ActiveXObject("Microsoft.XMLDOM");
		    xmlObjectA.async=false;
		}
		else if(document.implementation && document.implementation.createDocument)
		{
		    var xmlObjectA = document.implementation.createDocument("","",null);
		}
		var loadRes=xmlObjectA.load("/site/costumerReservation/cancel.hx.asp")			
			if(!loadRes){
				alert("LOADING ERROR:"+xmlObject.parseError.reason)
				}
			else{
				var raws=xmlObjectA.documentElement.selectNodes("row")	
				//alert(raws.length)
				}}					
	catch(e){
		alert("ERROR:"+e.description)
		}
}

//------------------------------------------------//
// RejectBadInput	:
// 	parameter	: input (String)
// 	return		: True / False
// 
// The function checks the [input] String for containg sql commands. 
// It rerturns  :
//	true 	- if there are any sql commands
//	false 	- otherwize.

function RejectBadInput (input){
	var known_bad = new Array ("select","insert","delete","update","drop","--","'");
	var login_flag = true;
	var oldInput=String(input);
	
	for (icon=0;icon<known_bad.length ; icon++){
		if (oldInput.indexOf(known_bad[icon])>-1)
			return false;
	}
	return true
}
//--------------------------------------------------//
	function isValidDate(sdate){
		 var sDate = sdate.split("/");
		 var monthDays	= "31,28,31, 30, 31, 30, 31, 31, 30, 31, 30,31"
		 monthDays = monthDays.split(",");
    	 var year		= sDate[2]
       var _month		= sDate[0]
       var days      = sDate[1]
       
       //february
       if(sDate[0]==2){
			
			if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
							monthDays[1] = 29;
			
			if(1*sDate[1]>1*monthDays[1]){
				return false
			}else return true
		}
		var monthIndex = sDate[0]-1
		if(1*sDate[1]>1*monthDays[monthIndex])	return false
		else return true						
	
	}

//----------------------------------------------------//
// AllowGoodInput	:
// 	parameter	: input (String)
// 	return		: True / False
// 
// The function checks the [input] chars. 
// It rerturns  :
//	true 	- if there are only EN letters or numbers
//	false 	- otherwize.

function AllowGoodInput (input){
	var known_good = "abcdefghijklmnopqrstuvwxyz_ABCDEFGHIJKLMNOPQRSTUVWXYZ01923456789";
	var login_flag = true;
	var currentChar;
	var oldInput=String(input);
	
	for (i=0 ; i<oldInput.length ; i++){
		currentChar=oldInput.charAt(i);
		
		if(known_good.indexOf(currentChar)==-1){
			return false;
		}	
	}
	return true
}
//--------------------------------------------------------//
function showAltClick(text,obj,leftt,topt,lang)
	{
		
		if(lang!="EN") return;
		var top  =  window.event.clientY + window.document.body.scrollTop-50
		var left =  window.event.clientX + window.document.body.scrollLeft-50
		
		
		if(leftt)left = leftt
		if(topt)top = topt  
		
		if (tip.style.display == 'none'){
				tip.style.display = 'inline';
			
				if(obj.offsetLeft<0)
					tip.style.pixelLeft = left;
				else	
					tip.style.pixelLeft = left
				tip.style.pixelTop  = top
				message.innerHTML = unescape(text);
		}		
	}
//---------------------------------------------------//
function closeAlt(){
		tip.style.display="none";
}
//---------------------------------------------------//

function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}
///////////////////////////
function findPosY(obj)
{
   var curtop = 0;
   if(obj.offsetParent)
       while(1)
       {
         curtop += obj.offsetTop;
         if(!obj.offsetParent)
           break;
         obj = obj.offsetParent;
       }
   else if(obj.y)
       curtop += obj.y;
   return curtop;
}
/////////////////////////////
function DatesDiff(interval,theDate1,theDate2)
{
	//if(!ff)		return DatesDiff_vb(interval,theDate1,theDate2)

	var oDate1 = new Date(theDate1);
	var oDate2 = new Date(theDate2);
	var hoursfromtoday = Math.ceil((oDate2.getTime()-oDate1.getTime())/(1000*60*60));
	//alert("JS DatesDiff=" + hoursfromtoday);
	return hoursfromtoday;
}
///////////////////////////////////
function fireClickEvent(control)
{ 
    if (document.all) 
    { 
        control.fireEvent("onclick"); 
    } 
    else 
    { 
        var clickEvent = window.document.createEvent("MouseEvent"); 
        clickEvent.initEvent("click", false, true); 
        control.dispatchEvent(clickEvent); 
    } 
} 

function trim(arg)
{
	try
	{
		var str = String(arg);
		return str.replace(/^\s+|\s+$/mig, "");
	}
	catch(e){
		return ""
	}
}