﻿onLoadArr = new Array;
function onLoadPage(){
	var n
	for(n=0;n<onLoadArr.length; n++){
			objType = typeof(onLoadArr[n])
			if(objType=="string"){
			//	eval(onLoadArr[n])	
			}else if(objType == "function"){
				onLoadArr[n]()
			}
			//alert(onLoadArr[n])
	}
	
	
}

var agt,MSIE
agt=navigator.userAgent.toLowerCase();
NAV = agt.indexOf('netscape')!=-1
FFOX=agt.indexOf('firefox')!=-1
MSIE =agt.indexOf('msie')!=-1



function overFlashIconAssos(objName){
	var obj = eval("document." + objName)
	obj.GotoFrame(1)
	obj.Play()
	}
function outFlashIconAssos(objName){
	var obj = eval("document." + objName)
	
	obj.GotoFrame(5)
	obj.Play()
	}


var CIO
function openCal(p){
	CIO= document.getElementById(p)
	MSIE?openDialog2("/admin/html/culc.html",205,290):WOpener("/admin/html/culc.html",205,290);
}
function setCal(day1, month1, year1){
	CIO.innerHTML=day1 + "/" + month1 + "/" + year1
	eval("fo01.p_day.value='"+day1+"'")
	eval("fo01.p_month.value='"+month1+"'")
	eval("fo01.p_year.value='"+year1+"'")

}

var popstageS
function WOpener(lnk,winwid ,winhigh,scrol,resize ){
	if(resize==null)resize=0
	if(scrol==null)scrol=0
	if(popstageS!=null){popstageS.close();}
	if(winwid==null){winwid = 100}
	if(winhigh==null){winhigh=100}
	popstageS =  window.open(lnk,'tour', 'width='+winwid+',height='+winhigh+',scrollbars='+scrol+',left=50,top=20,menubar=0,location=0,toolbar=0,status=0,resizable='+resize)
	
	sti=setTimeout("if(window.document.popstageS)window.popstageS.focus()",3000)

	}
flashShow=function(w,h,s,name){
	if(name==null)name="fl999"
	document.write( '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="'+w+'" height="'+h+'" id="'+name+'" align="middle">'+
		'<param name="allowScriptAccess" value="sameDomain" >'+
	'<param name="movie" value="'+s+'" >'+
	'<param name="menu" value="false" >'+
	'<param name="quality" value="high" >'+
	'<param name="wmode" value="transparent" >'+
	'<param name="bgcolor" value="#ffffff" >'+
	'<embed src="'+s+'" menu="false" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+w+'" height="'+h+'" name="'+name+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" >'+
	'</object>')
	}
	
function changeFV(flashName,str){
	flashName = "flashBtn";
	window.document[flashName].SetVariable("_root.pos", str);
	if(document.sample) eval('document.'+ flashName + '.SetVariable("_root.pos", str)')
}


function emailVal(string){
valid = false
for (n=3;n<string.length;n++){
 	if(string.charAt(n)=="@" && n < (string.length - 5) ){
		for(nn=string.length-5;nn<string.length-2;nn++){
		if(string.charAt(nn)=="."){
		valid = true
		}		
		}	
	}		
}
return valid
}
function mapPointer(L,T){

}
function phoneVal(string){
	string = string.split(" ");
	string = string.join("");
	string = string.split("-");
	string = string.join("");
	p_phone_digits = 0
	re  = false
	for (n=0;n< string.length;n++){
			if (!isNaN(string.charAt(n))){
			p_phone_digits++
					if(p_phone_digits>7){
						re = true
						break;
					}
			} else {
			 p_phone_digits = 0	
			}
	}
	return re;
}


function brkAnd(t){
	t = t.split("&")
	t=t.join("OOTWOO")
	t = t.split(String.fromCharCode(13))
	t=t.join("<br>")
	t = t.split(String.fromCharCode(8))
	t=t.join()
	t = t.split(String.fromCharCode(9))
	t=t.join()
	t = t.split(String.fromCharCode(10))
	t=t.join()
	t = t.split(String.fromCharCode(11))
	t=t.join()
	t = t.split(String.fromCharCode(12))
	t=t.join()
	return t
}
function dhtmlLoadScript(url)
{
   var e = document.createElement("script");
   e.src = url;
   e.type="text/javascript";
   document.getElementsByTagName("head")[0].appendChild(e); 
   
}
function toMany(p){
	if(p.value.length>400){
		tmp=p.value.substring(1,400)
		p.value=tmp
	}

}
overDiv=function(ob){
	ob.style.backgroundColor="#000066"
	ob.style.color="#ffffff"
}
outDiv=function(ob){
	ob.style.backgroundColor=""
	ob.style.color=""
}
function clrPx(p){
	return eval(p.substring(0,p.indexOf("px")))
}

function openDialog(lnk,wi,hi){
	dial = window.showModalDialog("/admin/dlFrame.asp?"+lnk,window,'dialogHeight:'+hi+'px;dialogWidth:'+wi+'px;status:0;help:0;center:1;help:1;unadorned:0;scroll:no;status:yes;')
	return dial
	}
function compr(str,comp){
	tmpA=" "+str+" "
	tmpB=" "+comp+" "
	if(tmpB.indexOf(tmpA)>-1)
		return str
	else
		return ""
	}
function LTrim( value ) {
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

// Removes ending whitespaces
function RTrim( value ) {
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

// Removes leading and ending whitespaces
function trim( value ) {
	return LTrim(RTrim(value));
}
function input_MD_checkNumeric(obj){
	old_value = obj.value
	obj.onkeyup = function(){
	if(isNaN(obj.value) ){
		n = obj.value.length
		for(i=n;i>0;i--){
			if (isNaN(obj.value))
				obj.value = obj.value.substring(0,n-1)
				
			}
		}
	}
}
function ajaxObj(url, Qform, Method){
	//prompt('', url)
	if(!Method) Method = "POST"
	if (!Qform)Qform = ""
	var xmlHttp;
	var xmlHttp;
	try { 
		// Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest(); 
	}catch (e){  // Internet Explorer  
		try	{ 
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); 
		}catch (e){  
			try{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");     
			}catch (e){ 
				alert("Your browser does not support AJAX!");
				return false;      
			}
		}
	}
	//xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	xmlHttp.open(Method,url,true);
	xmlHttp.send(Qform)
	return xmlHttp
}
function getStyle(obj, styleName){
 	if(window.getComputedStyle){
		return window.getComputedStyle(obj,null).getPropertyValue(styleName)
	}else{
		return  eval("obj.currentStyle." + styleName)			
	} 
	
}
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 [ scrOfX, scrOfY ];
}
function getWinSize() {
  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 [ myWidth, myHeight ];
  
}

var floatWin
function goContact(e){
	
	if(floatWin){
		floatWin.closeIMAGE.onclick()
	}
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	//if (targ.nodeType == 3) // defeat Safari bug
	//	targ = targ.parentNode;
	//alert(targ)
	papaDiv = targ.parentNode.parentNode

	floatWin = document.createElement("DIV")
	floatWin.className= "floatWin"
	floatWin.startMe = winBehave
	floatWin.startMe(papaDiv)
	papaDiv.appendChild(floatWin)
	floatWin.style.top=  papaDiv.offsetHeight + "px"
}

function winBehave(obj){
	var ME = this
	quar= obj.getAttribute("at_query")
	
	
	
	ME.innerHTML = '<table border="1" cellspacing="0" cellpadding="0" class="contactWinMain">\
					<tr>\
						<th id="win_title" height="20"><img src="/images/closeWin.gif" width=18 height=17 id="closeIMG"></th>\
					</tr>\
					<tr>\
						<td id="win_content" bgcolor="#FFFFFF"><iframe src="list_contact.asp?'+ quar +'"  style="margin:0px;" width="395" height="100%" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe> </td>\
					</tr>\
				</table>'	
	ME.closeIMAGE = ME.getElementsByTagName("IMG").closeIMG
	ME.closeIMAGE.onclick = function(){
		obj.removeChild(ME)
		floatWin = false
	}
	
}
function deleteNode( nodeObj){
	inOb = nodeObj.parentNode
	try{
		inOb.removeChild(nodeObj)
	}catch(e){
		try{
			nodeObj.removeMe(true)	
		}catch(e){
			try{
				nodeObj.removeNode(true)
			}catch(e){
				return false
			}
		}		
	}
	return true
}
function isDate(dateStr) {
	
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	
	if (matchArray == null) {
		//alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
		return false;
	}
	
	month = matchArray[3]; // p@rse date into variables
	day = matchArray[1];
	year = matchArray[5];
	
	if (month < 1 || month > 12) { // check month range
		alert("Month must be between 1 and 12.");
		return false;
	}
	
	if (day < 1 || day > 31) {
		//alert("Day must be between 1 and 31.");
		return false;
	}
	
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Month "+month+" doesn`t have 31 days!")
		return false;
	}
	
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day > 29 || (day==29 && !isleap)) {
			alert("February " + year + " doesn`t have " + day + " days!");
			return false;
		}
	}
	return true; // date is valid
}
function getBodyProportions(){
	var  myBodyWidth = 790
	var myBodyHeight = 490;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myBodyWidth = window.innerWidth;
		myBodyHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myBodyWidth = document.documentElement.clientWidth;
		myBodyHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myBodyWidth = document.body.clientWidth;
		myBodyHeight = document.body.clientHeight;
	}
	return [myBodyWidth,myBodyHeight]
	
}

function goto_gogalilee2009(){
	document.location.href = "http://www.gogalilee2009.org"

}
function trace(p){
		try{
			console.log(p)
		} catch(e){}	
		
}

function insertAfter(parent, node, referenceNode){
	if(referenceNode.nextSibling){
		parent.insertBefore(node, referenceNode.nextSibling);
	} else {
		parent.appendChild(node);
	}
}





_$$ = function(x){return " return  "+ x +".getElementsByTagName(p)"}

function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClassName(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClassName(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
function switchTitles(str, alt){
	if(str){
		if(trim(str).length>0){
			return str	
		}
	}
	return alt	
}
var  request = function(p){
	var ME = this
	ME.x="a"
	url = document.location.href
	qMarkIndex = url.indexOf("?")
	ME.queryString = {} 
	if(qMarkIndex>0){
		var query =url.substring(url.indexOf("?")+1, url.length)
		queryArr = query.split("&")
		for(var n=0; n<queryArr.length; n++){
			t= queryArr[n].split("=")
			if(t.length>1){
				ME.queryString[t[0]] = decodeURI(t[1])
			}
		}
	}
	return ME
}()



function getPageInnerSize(){
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		return {width:window.innerWidth, height:window.innerHeight}
	}else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		return {width: document.documentElement.clientWidth, height: document.documentElement.clientHeight}
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		return {width:  document.body.clientWidth, height: document.body.clientHeight}
	}
}
function merge(a,b){
	for(var t in b) a[t] = b[t]
	return a
	
}

/*  URL encode / decode  http://www.webtoolkit.info/ */
var Url = {
	// public method for url encoding
	encode: function(string) {
		return escape(this._utf8_encode(string));
	},
	// public method for url decoding
	decode: function(string) {
		return this._utf8_decode(unescape(string));
	},
	// private method for UTF-8 encoding
	_utf8_encode: function(string) {
		string = string.replace(/\r\n/g, "\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {
			var c = string.charCodeAt(n);
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if ((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
		}
		return utftext;
	},
	// private method for UTF-8 decoding
	_utf8_decode: function(utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while (i < utftext.length) {
			c = utftext.charCodeAt(i);
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if ((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i + 1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i + 1);
				c3 = utftext.charCodeAt(i + 2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
		}
		return string;
	}
}

var regExpEmail =  /^[a-zA-Z0-9@\-\.\'\_]+$/
var regExpemailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/; 
var regNumbers =  /^[0-9]+$/
	
