
/*****************************************************************************
* Site: J_functions.js
******************************************************************************
* collection of global functions
******************************************************************************
*	'-------------------------------------------------------------------------*
*	' Write By		: yossi Aharoni & ilan mazuz										  *
*	' Company		: Scepia LTD															  *
*	' Date			: Febuary 2001															  *
*	' updated at	:18/06/2001																  *
******************************************************************************
* Contents:
*
* - checkForFlash()    							: for natscape
* - changeLinkColor(obj,mouseOver)			:
* - changeLinkColor(obj,mouseOver)			:
* - imgOnOff(img,on)								:
* - NavRollOver(obj,bgColor,fontColor)		:
* - NavRollOut(obj,bgColor,fontColor)		:
* - checkForm(whatToCheck,theAction)		:
* - checkMultiForm(theForm,theAction)		:
* - hidemenus(i)									:
* - img_on_off(imgNum,on)						:
* - goToAddress(address)						: nevigate to 'address'
* - openPopUp(address)							: pop up the 'address'
* - showHideDiv(obj)								:
* - showHideDiv2(obj)							: get a literal name of the div-not object like the regular 'showHideDiv' func
* - divOnOff(div,cancelBubble,on)			:
* - isnull()										: Tests whether the given argument is empty or null
* - iif(q,truePart,falsePart)					: the clasic iif of vb
* - nz(param,val)									: if the param is null or 0 return val or "" if val not sopplied
* - checkEmail(email)							: email validation
* - dbg2File(msg, fname)						: print 2 file 'msg'
* - hasVScroll()									://check for vertical scroll bars
* - cleanCData(str)								: cleans the <![CDATA[]]> tags from a string .//Add by Moshe Pinchas
* - seccessMessege(string msg,string title,px top,px left)						:	open and locate div with success message from top and left px
* - seccessMessegeMouseClick(string msg,string title,px top, px left)			:	open and locate div with success message from mouse click to and lift px
* - closeSeccess()								:	close and alocate this div
* - isValidDate()								:	check if a day of the month is a valid one:
* 
********************************************************************************/
var dbgString = "";//global var for debuging 2 file in the system
var ns = false;
var ie = false;
if (document.layers) ns = true;
if (document.all) ie = true;

//*******************************************************************

//initilize java var for upper bar-only for home page used
var IsFlashMode=true;

//*******************************************************************

var xmlArr=new ActiveXObject("Microsoft.XMLDOM");
xmlArr.async=false

//*******************************************************************
function onChange(obj,sub,product){
	//window.open("/site/getSubFolders.hx.asp?selectBy=" + product);
	xmlArr.load("/site/getSubFolders.hx.asp?selectBy=" + product);
	xml2options(xmlArr,sub)
}

//*******************************************************************
function   getAgencyName(obj,sub,product){
	//window.open("/site/travelAgent/getSubFolders.hx.asp?selectBy=" + product);
	xmlArr.load("/site/travelAgent/getSubFolders.hx.asp?selectBy=" + product);
	xml2options(xmlArr,sub)
}

//*******************************************************************

function xml2options(xmlArr,sel){
	var elems = xmlArr.selectNodes("//ROWSET/ROW");
	
	if(elems.length>0)
		sel.length=elems.length;
	else
		sel.length=elems.length+1;
	if(elems.length==0){
		sel[0].text="choose location"
		sel[0].value=0;
	}	
	sel[0].selected=true;
	for (var i=0; i < elems.length; i++) {
		var e = elems.nextNode();
		sel[i].text=e.getAttribute("name");
		sel[i].value=e.getAttribute("id");
	}
}

////////////////////////////////////////////////////////
function round(number, X){
		 X = (!X ? 0 : 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,3})+$/;
	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.all["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.all(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.all(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 
}



/////////////////////////////////////////////////////////////////////////////////////////
	// 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.all['seccessMessege'].innerHTML=msg;
	document.all['messageTitle'].innerHTML=title;
	document.all['seccess'].style.display="";
		
	if (top==null){
		messageTitle
		document.all['seccess'].style.top=window.screen.height/2-document.all['seccess'].offsetHeight/2;
		document.all['seccess'].style.left=window.screen.availWidth/2-document.all['seccess'].offsetWidth/2
		window.focus();
	}else{
		document.all['seccess'].style.top= event.clientX-top;
		document.all['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.all['seccessMessege'].innerHTML=msg;
	//document.all['seccessMessege'].style.font-family="verdana"
	document.all['messageTitle'].innerHTML=title;
	document.all['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.all['seccess'].style.top=600;
			document.all['seccess'].style.left=250;
		}
		else if(noTop ==2){
			document.all['seccess'].style.top=800;
			document.all['seccess'].style.left=250;
		}
		else{
			if(new_top > 125 || new_top < 100){
				document.all['seccess'].style.top=200;
			}
			if(new_left > 310 || new_left< 100){
				document.all['seccess'].style.left=250;
			}
		}
	}
	else{
		document.all['seccess'].style.top=new_top;
		document.all['seccess'].style.left=new_left;
	}
	window.focus();
}
/////////////////////////////////////////////////////////////
function closeSeccess(){
	try{showObj(document.all.contactDiv);
	}catch(e){}
	document.all['seccess'].style.display="none";
	document.all['seccessMessege'].innerHTML="";
	document.all['seccess'].style.top=0;
	document.all['seccess'].style.left=0;
}




////////////////////////////Form Vaildation////////////////////////////////////////

function chackcancel(theForm){
	
if(theForm.resnum.value == ""){
	seccessMessege("Please enter booking 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 Booking 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.pickdayC.value+"/"+theForm.pickmonthC.value+"/"+theForm.pickyearC.value
theForm.pick_up_dateO.value  = theForm.pickyearC.value+"-"+theForm.pickmonthC.value+"-"+theForm.pickdayC.value

	
	//theForm.submit()
	
	
	theForm.submit()
	//findOrder()	
}

function findOrder(){
var areaXml;
	try{
		var xmlObjectA=new ActiveXObject("Microsoft.XMLDOM");
		xmlObjectA.async=false;
		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)
		}
}


///////////////////////////////////////////////////////////////////////////////////////
/*******************************************************************/
/********************check paiment validation functions*******************/
/*******************************************************************/

	var clickToPay = false;
	function goToPay(){
		if(validCreditCard(document.payment)&&!clickToPay){
			document.payment.submit();
			clickToPay = true;
		}	
	}
	
function validCreditCard(obj){
	var alertStr="";

/*	for(var index=0;index<obj.length;index++){
		if(obj.item(index).value==""){
			switch(obj.item(index).name){
				case "id_number":alertStr = "מספר תעודת זהות"; break;
				case "name_on_card":alertStr = "את שם בעל הכרטיס"; break;
				case "card_num4":alertStr = "מספר כרטיס תקין"; break;
				case "card_num3":alertStr = "מספר כרטיס תקין"; break;
				case "card_num2":alertStr = "מספר כרטיס תקין"; break;
				case "card_num1":alertStr = "מספר כרטיס תקין"; break;
				case "expireMonth":alertStr = "חודש בשדה תוקף כרטיס"; break;
				case "expireYear":alertStr = "שנה בתוקף כרטיס"; break;
				case "card_type":alertStr = "סוג כרטיס"; break;
				
			}
		
			if (alertStr!=""){
				alert("עליך למלא "+alertStr);
				obj.item(index).focus();
				return false;
			}	
		}	
		if(isNaN(obj.card_num1.value)){
			 alert("you have to enter numbers only")
			 obj.card_num1.focus();
			 return
		}
		if(isNaN(obj.card_num2.value)){
			alert("you have to enter numbers only")
			obj.card_num2.focus();
			return
		}
		if(isNaN(obj.card_num3.value)){
			alert("you have to enter numbers only")
			obj.card_num3.focus();
			return
		}
		if(isNaN(obj.card_num4.value)){
			alert("you have to enter numbers only")
			obj.card_num4.focus();
			return
		}
	}
	
	//===========check for valid numbers================
	
	var strCard = obj.card_num1.value + obj.card_num2.value + obj.card_num3.value + obj.card_num4.value;
		
	return(Checkcc(strCard, obj.card_type.value));*/
}
function Checkcc(ccnumber,cctype){
	//ccnumber = (credit_card_form.card_num1.value+credit_card_form.card_num2.value+credit_card_form.card_num3.value+credit_card_form.card_num4.value)
    
	/*var checkcc=0
	ctype=cctype.toUpperCase()
	number=Trimtodigits(ccnumber)
	switch (ctype)
	{
		case "1":
			if (number.substring(0,4)=="4580"){
				return true
			}else{
				 alert("מס' שגוי! נסה שנית")
				 return false;
			   
			} 
			 break;
		case "3":
			if (number.substring(0,4)=="3755"){
				return true;
			}else{
				alert("מס' שגוי! נסה שנית") 
				return false;
			} 
			break;
		case "2":
			if (number.substring(0,2) =="36"){
				return model10(number);
			}else{
				alert("מס' שגוי! נסה שנית") 
				return false;
			      
			} 
		 break;
		case "4":
			switch (number.length){
				case 8:                     
					
					if (number.substring(0,1)=="1" || number.substring(0,1)=="2" || number.substring(0,1)=="3" || number.substring(0,1)=="4"){
						return model11(number);
					}else{
						alert("מס' שגוי! נסה שנית") 
						return false;
					} 
					break;	
				
				case 9:
					if (number.substring(0,2)="8"){
						return model11(number);
					}else{
						alert("מס' שגוי! נסה שנית")  
						return false;
					} 
					 break;
				case 16:
					if (number.substring(0,5) =="53261")
					{
						return true;
					}
					else
					{
					   alert("מס' שגוי! נסה שנית")  
					   return true;
					} 
					break;
			}
	
		case "U":
			if (number.substring(0,4) =="4128")
			{
				return model10(number);
			}
			else
			{
				alert("מס' שגוי! נסה שנית")
				return false;
			} 
		default:
			    alert("מס' שגוי! נסה שנית")
			    return false;
	
	}*/
	

}

function Trimtodigits(tstring)
{
   /* var trimtodigits=""
	var s="";
	var ts=tstring + '';
	
	for (var x=0;x<=(ts.length-1);x++){
		ch=ts.substring(x,x+1)
		if (ch.charCodeAt(0)>=48 &&  ch.charCodeAt(0)<=57){s=s + ch}             
	}
		
	trimtodigits=s;
	return (trimtodigits);*/
}

///////////////////////////////////////////////////////////////////////
function model10(number1){
	/*var mmdel10 = "";
	var qsum,x,ch,sum;
	qsum = 0;
	
	for(x=1;x<=number1.length;x++){
		ch = number1.substring(number1.length-x+1,number1.length-x)
		ch = new Number(ch);
		if(x%2==0){
			sum = 2*ch;
			qsum = qsum + (sum%10);
			if(sum>9) qsum = qsum + 1;
			else qsum = qsum +ch;
		}
	}
	
	if(qsum%10!=0){
		alert("מס' שגוי! נסה שנית")
		return false;
	}else return true;*/

}
///////////////////////////////////////////////////////////////////////
function model11(number1){
	/*var mmodel11="";
	var qsum,ch,x;
	qsum = 0;
	
	for(x=1;x<=number1.length;x++){
		ch = number1.substring(number1.length-x+1,number1.length-x)
		ch = new Number(ch);
		qsum = qsum+ch*x;
	}
	
	if(qsum%11!=0){
		alert("מס' שגוי! נסה שנית")
		return false;
		
	}else{
		return true
	} */	
	
}

/*******************************************************************/
/****************end of check paiment validation functions*****************/
/*******************************************************************/

//-----------------------------------------------------------------------------------//
// 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 breakLine(left,right,colspan){
	
	left	= isnull(left)  ? "" : "padding-left:"+ left + "px;"
	right	= isnull(right) ? "" : "padding-right:"+ right + "px;"
	colspan = isnull(colspan) ? "" : 'colspan="' + colspan + '"'
	var tmpStr = ""
	tmpStr ='<tr><td style="'+ (right + left) + '" '+  colspan +'> \
				<table border="0" height="1px" width="100%" cellspacing="0" cellpadding="0"> \
					<tr><td background="/site/images/hp/dots.gif" style="font-size:1px"><img src="/site/images/trans.gif" width="100%" style="height:1px"><br> \
					</td></tr> \
				</table></td></tr>'
	return tmpStr			
				
}

//-------------------------------------------------------------------
function showAltClick(text,obj,leftt,topt)
	{
		//alert("event.clientX:"+event.clientX+" event.clientY"+event.clientY)	
		//alert("window.document.body.offsetHeight:"+window.document.body.offsetHeight)
		var top  =  window.event.clientY + window.document.body.scrollTop-50
		var left =  window.event.clientX + window.document.body.scrollLeft-50
		
		/*if (left > screen.availWidth || top > screen.availHeight) {
			left = (screen.availWidth -  300)/2;
			top = (screen.availHeight - 75)/2;
		}*/
		
		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 round2(number, X) {
  p = Math.pow(10,2);
  return (Math.round(number * p))/p;

}
//////////////////////////////////////////////////////////////////	
function getCoin(coinName){
	
	var sCoin = "";
	if(!coinName) return "";
	switch(coinName){
		case "EUR":sCoin = "<img src='/site/images/icons/ico_euro.gif' width=9 height=9>"
					  break;
		case "USD":sCoin = "<img src='/site/images/icons/ico_dollar.gif' width=7 height=11>"
					  break;			  
		case "GBP":sCoin = "<img src='/site/images/icons/ico_pound.gif' width=9 height=11>"
					  break;					  
		default:   sCoin = coinName
	}
	
	return sCoin;
}


