var __root='?';
function set_root(root){
	__root=root;
}
var price={
      init:
      function(input_name,mydiv,internaldiv){
        this.price_per_quantity_array=new Array();
        this.price_update_input=input_name;
        this.mydiv=mydiv;
        this.internaldiv=internaldiv;
      },
      
      set_price:
      function(index,price){    
        if(parseFloat(price)==NaN){
              return false;
        }     
        this.price_per_quantity_array[index]['price']=parseFloat(price);   
        this.to_str();
        return true;
      },
      
      set_quantity:
      function(index,quantity){
        if(parseInt(quantity)==NaN){
        	return false;
        }
        this.price_per_quantity_array[index]['quantity']=parseInt(quantity);
        this.to_str();
        return true;
      },
      
      to_str:
      function(){
        var str="";
        var len=this.max_index();
        for(var i=0;i<len;i++){
          if(this.price_per_quantity_array[i]['A']>0){
            if(str!='')str+=";";
            str+=this.price_per_quantity_array[i]['quantity']+","+this.price_per_quantity_array[i]['price'];
          }
        }
        if(isset(this.price_update_input)){
          $(this.price_update_input).value=str;
        }
        return str;
      },
      
      add:
      function(index,price,quantity){ 
        if(parseFloat(price)==NaN || parseInt(quantity)==NaN){
          return false;
        }
        this.price_per_quantity_array[index]=new Array;
        this.price_per_quantity_array[index]['price']=parseFloat(price);   
        this.price_per_quantity_array[index]['quantity']=parseInt(quantity);
        this.price_per_quantity_array[index]['A']=1;
        this.to_str();
        return true;
      },

      max_index:
      function(){
      	var len=this.price_per_quantity_array.length;
      	return len;
      },
      
      draw_add_price:
      function(doc,add_to_obj,quantity,price,del_text){
        var i=this.max_index();
        var add=this.add(i,price,quantity);
        if(add){
          var oTR=doc.createElement("TR");
          add_to_obj.appendChild(oTR);
          var tr_id='product_tr_'+i;
          oTR.setAttribute('ID',tr_id);
          var oqnttyTD=doc.createElement("TD");
          oqnttyTD.innerHTML='<input type="text" value="'+quantity+'" id="product_quantity_'+i+'" onblur="price.set_quantity('+i+',this.value)">';
          var opriceTD=doc.createElement("TD");
          opriceTD.innerHTML='<input type="text" value="'+price+'" id="product_price_'+i+'" onblur="price.set_price('+i+',this.value)">';
          var odelTD=doc.createElement("TD");
          odelTD.innerHTML='<input type="button" value="'+del_text+'" onclick="price.draw_del_price('+i+')">';
          oTR.appendChild(oqnttyTD);
          oTR.appendChild(opriceTD);
          oTR.appendChild(odelTD);
          this.make2innerhtml();
          return true;
        }
        return false;
      },
      
      del:
      function(index){
        this.price_per_quantity_array[index]['A']=0;     
        this.to_str();
      },
      
      draw_del_price:
      function(index){
        this.del(index);
        this.make2innerhtml();
        $('product_tr_'+index).style.display='none';        
      },
      
      add_new_prdct:
      function(add_to_obj,del_text){
        var qntt=$('new_qntty').value;
        var price=$('new_price').value;
        var add=this.draw_add_price(document,$(add_to_obj),qntt,price,del_text);
        if(add){
          $('new_qntty').value=parseInt($('new_qntty').value)+1;
          $('new_price').value='';
          this.make2innerhtml();         
        }else{
          alert("FATAL ERROR");
        }
      },
      
      draw_tfoot:
      function(){
      	$('price_and_quantity').value=this.to_str();
        var oTR=document.createElement("TR");
        $('all_prices_foot').appendChild(oTR);
        var oqnttyTD=document.createElement("TD");
        oqnttyTD.innerHTML='<input id="new_qntty" type="text" value="1">';
        var opriceTD=document.createElement("TD");
        opriceTD.innerHTML='<input id="new_price" type="text">';
        var odelTD=document.createElement("TD");
        odelTD.innerHTML='<input type="button" value="הוסף" onclick="price.add_new_prdct('+"'all_prices_tbody','מחק')"+'">';
        oTR.appendChild(oqnttyTD);
        oTR.appendChild(opriceTD);
        oTR.appendChild(odelTD);
        this.make2innerhtml();
      },
      
      make2innerhtml:
      function(from,internal){
      	if(isset(this.internaldiv)&&isset(this.mydiv)){
	      	 $(this.internaldiv).innerHTML=$(this.mydiv).innerHTML;
			 $(this.mydiv).innerHTML=$(this.internaldiv).innerHTML;
			 $(this.internaldiv).innerHTML='';
			 $(this.internaldiv).style.display='none';
      	}
      }
      
}

function dbg(obj){
	ret = '[';
	for(var i in obj){
		ret = ret +"\n["+i+"]"+"=>"+"'"+ obj[i]+"'";
	}
	ret = ret + ']';
	//if(!dump) return ret;
	
	vr = window.open();
	vr.document.write(ret);
}

function wino(strurl,pname,width,height){
var s = "width="+width+",height="+height;
var hauteur_popup=height;
var H = (screen.height - hauteur_popup) / 2;
var largeur_popup=width;
var L = (screen.width - largeur_popup) / 2;
var ww = ",top="+H+",left="+L;
vr = window.open(strurl,pname,"scrollbars,"+s+ww)    
vr.focus();
}

function open_pdf_window(pdf_id,root){
	var width=screen.width-10;
	var height=screen.height-60;
	var s = "width="+width+",height="+height+',status=no';
	var hauteur_popup=height;
	var H = (screen.height - hauteur_popup) / 2;
	var largeur_popup=width;
	var L = (screen.width - largeur_popup) / 2;
	var ww = ",top=0,left=0";			
	var strurl=__root+'a=homepage/showfile&id='+pdf_id+'&v'+nowadays();
	var vr = window.open(strurl,"movie","scrollbars,"+s+ww)    
	vr.focus();
}

function show_pdf(pdf_id){
	open_pdf_window(pdf_id);
	/*var src='?a=homepage/show_pdf&pdf_id='+pdf_id;
	call_server(src);*/
}
var oldtd='';
var oldwindiv='';
function show_lesn_details(masechet_id,page_num,date,lang,target1,target2){

	if($('stageonload')!=null && $('stagenload')!=undefined){
		$('stageonload').style.visibility='visible';
	}
	//$('stageonload').style.visibility='visible';
	if ($('col_'+masechet_id+'_'+page_num)!=null && $('col_'+masechet_id+'_'+page_num)!=undefined){
		var elmnts=document.getElementsByClassName($('calander_tbody'),'cur');
		for(var i=0;i<elmnts.length;i++){
			elmnts[i].className='';
		}
		$('col_'+masechet_id+'_'+page_num).className='cur';
	}

	var i;
	//for(i=0;i<600000000;i++){
	//}
	var src=__root+'a=homepage/draw_lessones_details&masechet_id='+masechet_id+'&page_num='+page_num+'&date='+date+'&lang='+lang+'&l='+lang+'&target1='+target1+'&target2='+target2;

	call_server(src,true,true);	

	if (isset('all_windiv_'+masechet_id+'_'+page_num)){
		if (isset($(oldwindiv))){
			$(oldwindiv).style.display='none';
		}
		if(($('all_windiv_'+masechet_id+'_'+page_num) != null) && ($('all_windiv_'+masechet_id+'_'+page_num) != undefined)){
			$('all_windiv_'+masechet_id+'_'+page_num).style.display = 'block';
		}
		oldwindiv='all_windiv_'+masechet_id+'_'+page_num;
	}
}

function om(strid){
	width=screen.width-10;
	height=screen.height-60;
	var s = "width="+width+",height="+height+',status=no';
	var hauteur_popup=height;
	var H = (screen.height - hauteur_popup) / 2;
	var largeur_popup=width;
	var L = (screen.width - largeur_popup) / 2;
	var ww = ",top=0,left=0";
	strurl=__root+"a=stream/main&id="+strid;
	vr = window.open(strurl,"movie","scrollbars,"+s+ww)    
	vr.focus();
}

function od(iid){
	wino('?a=admin/admindedication/adminadd&id='+iid,'user','450','450')
	}
	
	function ou(iid){
	wino('?a=admin/adminusers/userdetails&id='+iid,'user','450','550')
	}
	
	function oi(iid,mode){
	wino('?a=admin/contents/imgupload&id='+iid+'&mode='+mode,'imgup','450','450')
	}
	function oni(iid,mode,area){
	wino('?a=admin/contents/imgupload&mode='+mode+'&div='+area,'imgup','450','400')
	}
	
		function ob(iid){
	wino('?a=admin/paymentdetails&id='+iid,'payment','300','350')
	}
	
	function map(iid){
	wino(__root+'a=homepage/display&id='+iid,'payment','300','350')
	}
//function handle date field (dd/mm/yy)
function do_date(obj)
{
	if(event.keyCode==8)
		return;
	len=obj.value.length;
	str=obj.value;
	switch(len)
	{
		case 1:
	  	case 4:
	  	default:
			sub=str.substring(str.length-1,str.length);
   	    	if (isNaN(parseInt(sub)))
	    	{
	    		alert("illegal date");
		  		obj.value=str.substring(0,str.length-1);
		  		return;
			}
			break
		case 2:
	   		if (str.charAt(1)=='/')
	   		{
		 		obj.value=new String("0")+str;
		 		return;
	   		}
	   		day=parseInt(str);
	   		
	   		if (isNaN(day))
			{
				alert("illegal date");
				obj.value=value=obj.value.substring(0,obj.value.length-1);
				return;
			}
			if (day==0)
			   day=parseInt(str.substring(1,2));
			if (day>31 ||day<1)
			{
				alert("illegal date");
				obj.value=value=obj.value.substring(0,obj.value.length-1);
				return;
			}
	    	obj.value=obj.value+'/';
	  		break;
		case 5:
	   		if (str.charAt(4)=='/')
	   		{
		  		obj.value=str.substring(0,3)+'0'+str.charAt(3)+'/';
		  		return;
	   		}
	   		temp=str.substring(3,5);
	   		mon=parseInt(str.substring(3,5));
	   		if (mon==0)
			  mon=parseInt(str.substring(4,5));
	   		if ((isNaN(mon)) || ((mon<1) || mon>12))
	   		{
	   			alert("illegal date");
	   			obj.value=obj.value.substring(0,obj.value.length-1);

			}
	   		else
  		 		obj.value+='/';
  				break;
	
	}
}

function readCookie(name) {
	var start =cookies.indexOf(name + "=");
	start=cookies.indexOf("=",start)+1;
	var end=cookies.indexOf(";",start);
	if (end==-1){
		end =cookies.length;
	}
	//alert(name+':'+cookies.substring(start,end))
	var value = unescape(cookies.substring(start,end));
	
	if (value==null){
		value =0;
	}
	return value;
}

function setCookie(name,value){
	//alert(cookieExpire)
	//alert(cookieExpire.toGMTString());
	document.cookie=name+'='+value+';expires='+cookieExpire.toGMTString();
	//alert(document.cookie);
}

function validDate(day,month,year){
	var monthsArr = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug" ,"Sep", "Oct", "Nov", "Dec");
	var daysArr = new Array;
	for (var i=0; i<12; i++) {
		if(i!=1) {
			if((i/2)==(Math.round(i/2))) {
				if(i<=6) {
	 				daysArr[i]="31";
				} else {
	 				daysArr[i]="30";
				}
			} else {
				if(i<=6) {
	 				daysArr[i]="30";
				} else {
	 				daysArr[i]="31";
				}
			}
		} else {
			if((year/4)==(Math.round(year/4))) {
				daysArr[i]="29";
			} else {
				daysArr[i]="28";
			}
		}
	}
	if(parseInt(day)>parseInt(daysArr[month])) {
		alert(monthsArr[month] + ' ' + year + ' does not have ' + day + ' days.');
		return false;
	}
	return true;
}

//this function parses the arguments for validDate() from an editbox
function datecheck(obj)
{
  str=obj.value;
  day=parseInt(str.substring(0,2));
  mon=parseInt(str.substring(3,5));
  year=str.substring(6,8);
  if (day==0)
	 day=parseInt(str.substring(1,2));
  if (mon==0)
	mon=parseInt(str.substring(4,5));
  tempyear=new Date().getFullYear();
  tempyear++;
  year="20"+year;
  year=parseInt(year);
  if (year > tempyear )
	year-=100;
  mon--;
  if(validDate(day,mon,year)==false)
	obj.value="";
}

function time(){
	return nowadays();
}
//used for unique url to avoid browsers cache
function nowadays() {
	dt = new Date();
	return dt.getDate()+"_"+dt.getMinutes()+"_"+dt.getSeconds()+"_"+dt.getMilliseconds();
}

function show_hide_div(divid){
	if (document.getElementById(divid)==null)
	    return;
	div=document.getElementById(divid).style;
	div.display=(div.display=='') ? 'none' : ''; 
}


function addSelect(selectObj,vlu,str)
{
	if (vlu==-1)
	  return;
	if (str=="")
	  return;
	var addIndex=0;
	var len=selectObj.options.length;
	var text="";
	var i;
	for (i=0;i<len;i++)
	{
		text=selectObj.options[i].text;
		if (text==str)
		  return;
		if (text>str)
		  break;
		addIndex++;
	}
	i=len;
	selectObj.options[len]=new Option("","");
	while(i>addIndex)
	{
		selectObj.options[i].text=selectObj.options[i-1].text;
		selectObj.options[i].value=selectObj.options[i-1].value;
		i--;
	}
	selectObj.options[addIndex].text=str;
	selectObj.options[addIndex].value=vlu;
}

function TmoveBtweenSelects(selectfrom,selectto){
	sf = document.getElementById(selectfrom);
	st = document.getElementById(selectto);
	vlu=sf.value;
	indx=sf.selectedIndex
	if((vlu=="")&&(indx<0))
		return;
	var e= new Option("","");
	var f= new Option(sf.options[indx].text,vlu);
	len=sf.options.length-1;
	for(i=indx;i<len;i++){
		txt=sf.options[i+1].text;
		vlu=sf.options[i+1].value;
		sf.options[i]=new Option(txt,vlu);
		if(i%2){
		sf.options[i].calssName="m0";
		}
	}
	sf.options[len]=e;
	sf.options.length=sf.options.length-1;
	len=st.options.length-1;
	addSelect(st,f.value,f.text);
	/*for(i=0;i<len;i++){
			vl=st.options[i].value;
			if(vl==vlu) return;
	}
	st.options[st.options.length]=f;*/
}

function TmoveBtweenSelectsObject(sf,st){
	vlu=sf.value;
	indx=sf.selectedIndex
	if((vlu=="")&&(indx<0))
		return;
	var e= new Option("","");
	var f= new Option(sf.options[indx].text,vlu);
	len=sf.options.length-1;
	for(i=indx;i<len;i++){
		txt=sf.options[i+1].text;
		vlu=sf.options[i+1].value;
		sf.options[i]=new Option(txt,vlu);
		if(i%2){
		sf.options[i].calssName="m0";
		}
	}
	sf.options[len]=e;
	sf.options.length=sf.options.length-1;
	len=st.options.length-1;
	for(i=0;i<len;i++){
			vl=st.options[i].value;
			if(vl==vlu) return;
	}	
	st.options[st.options.length]=f;
	return;
}

function select_all_options(obj){
	if(obj.multiple !=1) obj.multiple=1;
	for(a=0;a<obj.options.length;a++) obj.options[a].selected=1;
}

function validate_input(str,rgxp)
{
	var result;
	if (str=="")
	    return true;
    results=str.match(rgxp);
	if (results==null)//no match at all
	    return false; //only part of the string matches
	if (results[0].length!=str.length)
	    return false;
	return true;
}
	    
function valid_seq_or_scn_code(edit)
{
	var rgxp;
	var str=edit.value;
	var str1=str+String.fromCharCode(event.keyCode);
	rgxp=/([0-9])+([a-zA-Z])?/;
	if(!validate_input(str1,rgxp))
		event.returnValue=false;
}

function validateemail(str){
	emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[a-zA-Z]$";
	var regex = new RegExp(emailReg);
	if (regex.test(str))
		return true;
	return false;
}

function listen(strid){
	width=screen.width-10;
	height=screen.height-100;
	var s = "width="+width+",height="+height;
	var hauteur_popup=height;
	var H = (screen.height - hauteur_popup) / 2;
	var largeur_popup=width;
	var L = (screen.width - largeur_popup) / 2;
	var ww = ",top=0,left="+L;
	strurl=__root+"a=stream/main&id="+strid+"&listen=1";
	vr = window.open(strurl,"audio","scrollbars,"+s+ww);
	vr.focus();
}

function download(id,stream){
	var wo=window.open(__root+'a=stream/pre_download&id='+id+'&stream='+stream,'download',"height=200,width=400,status=no,toolbar=no,menubar=no,location=no");
	wo.focus();
}

var bookmarkurl="http://www.hadafhayomi.co.il" 
var bookmarktitle="hadafhayomi" 
function addbookmark(){ 
if (document.all) 
window.external.AddFavorite(bookmarkurl,bookmarktitle) 
}
function sendToClipboard(s){
   if( window.clipboardData && clipboardData.setData ) {
      clipboardData.setData("Text", s);
   }
   else{
   	window.status='Error - For copy to cilpboard Internet Explorer required';
      //alert("Internet Explorer required");
   }
}

function mytrim(inputString) {
   // Removes leading white spaces from the passed string. 
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " "||ch=='\t' || ch=='\r' || ch=='\n')
   {
      // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " "|| ch=='\t' || ch=='\r' || ch=='\n') {
 // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   return retValue;
}
function call_server(url,is_uncach,is_async) {
	//null && document.getElementById(elmnt)!=undefined){
	if(is_async==null || is_async==undefined){
		is_async=false;
	}
	return ajax.Server(url,false,is_async,is_uncach);
}
function round_to_decimal_place(X, M){
  with (new Object(Math.round(Math.pow(10, M)*X)+''))
    { return substring(0,length-M)+
        '.'+substring(length-M,length)} }
function get_el(elmnt){
	return document.getElementById(elmnt);
}
function get_val(elmnt){
	return document.getElementById(elmnt).value;
}
document.getElementsByClassName = function(node, classname) {
    var elements = [];
    var re = new RegExp('(^| )' + classname + '( |$)');
    var children = node.getElementsByTagName("*");
    for (var i = 0, j = children.length; i < j; i++)
        if (re.test(children[i].className)) elements.push(children[i]);
    return elements;
}
function $(id){
	return document.getElementById(id);
}
/*function isset(parm){
	return ((parm != undefined) && (parm != null)) ? true : false;
}*/
function isset(elmnt){
	//alert(String(elmnt));
	if(document.getElementById(elmnt)!=null && document.getElementById(elmnt)!=undefined){
		return true;
	}
	if(String(elmnt)=='[object]'){
		return true;
	}
	if(String(elmnt)=='[object HTMLDivElement]'){
		return true;
	}
		if(String(elmnt)=='[object XMLHttpRequest]'){
		return true;
	}
	
	return false;
}
function addEvent(element, type, handler)
{
	
	if (element.addEventListener) {
		element.addEventListener( type, handler, false );
	}
	else if (element.attachEvent) {
		element["e" + type + handler] = handler;
		element[type + handler] = function() { element["e" + type + handler](window.event); }
		element.attachEvent("on" + type, element[type + handler]);
	}
}

var xmlSch=null;
var ajax = {
	Server:function(url,target,is_async,is_uncach){		
		if(!isset(is_uncach)){
			is_uncach=true;
		}
		var cUrl=url;
		var return_value=true;
		if(is_uncach){
			cUrl+='&v='+nowadays();
		}
		if(target){
			cUrl+='&target='+target;
		}
		if(is_async==null || is_async==undefined){
			is_async=false;
		}
		cUrl+='&at_ajax=1';		
		if(isset('ajax_debug_div')){
			if(!ajax.numLoading || ajax.numLoading<2){
				$('ajax_debug_div').innerHTML='';
			}
	   	$('ajax_debug_div').innerHTML+='<br/>'+cUrl+'&debug_mode=1';
	   }
	   var loaded=new serverLoad();
	   return loaded.sendAndLoad(cUrl,'GET',is_async);		
	},
	//expect to receive the xmlhttprequest object
	XmlToHtml:function(rslt){	
		var return_value=true;	
		if(xmlSch==null){
			if (window.ActiveXObject){				
				this.conname = new ActiveXObject('Microsoft.XMLHTTP');
				xmlSch = new ActiveXObject("Microsoft.XMLDOM");
				xmlSch.async = false;
			}else if(document.implementation && document.implementation.createDocument){				
				this.conname = new XMLHttpRequest();
				xmlSch = document.implementation.createDocument("", "doc", null);
				xmlSch.async = false;
			}
		}
		
		if (window.ActiveXObject){	
			xmlSch.load(rslt.responseXML);		
		}else{
			xmlSch=rslt.responseXML;
		}
	
			//xmlSch.onload();
	   var root=xmlSch.documentElement;		  
	   if(root==null || root==undefined){
	   	if(isset('ajax_debug_div')){
		   	//$('ajax_debug_div').innerHTML+="<br/>"+rslt.responseText;
		   	var win=window.open();		  
				win.document.writeln(rslt.responseText);
		   	//alert(cUrl + " can't found");
		   }

		
		   window.status='error at ajax praser';
		  //	alert( 'error at ajax praser');	
	   	//document.body.innerHTML=cUrl + " can't found";
	   	return null;
	   
	   }
	  
	   //window.open(cUrl);
	   var current_child=root.firstChild;
	   var i,j,k,id,attr,method_length,elmnt,val,nodev,fcs;
	   
	  
	   while(current_child!=null && current_child!=undefined){	   	
	   	if(current_child.nodeName=='todo'){
		   	for(i=0;i<current_child.getElementsByTagName('elmnt_id').length;i++){
		   		//document.getElementById('test1').getAttribute('style');
		   		elmnt=document.getElementById(current_child.getElementsByTagName('elmnt_id')[i].firstChild.nodeValue);
		   		val=current_child.getElementsByTagName('elmnt_val')[0].firstChild.nodeValue;
		   		if(current_child.getElementsByTagName('method')!=null && current_child.getElementsByTagName('method')!=undefined){
		   			method_length=current_child.getElementsByTagName('method').length-1;
			   		
			   		for(j=0;j<current_child.getElementsByTagName('method').length && elmnt!=null && elmnt!=undefined;j++){
			   			attr=current_child.getElementsByTagName('method')[j].firstChild.nodeValue;
			   			if(j==method_length){
			   				/*if (window.ActiveXObject){			   					
			   					elmnt.setAttribute(attr,val);
			   				}else{	*/		   					
			   					this.mozilaSetAttribute(elmnt,attr,val);
			   				/*}*/
			   			}else{
			   				elmnt=elmnt.getAttribute(attr);
			   			}
			   		}
		   		}
		   	}
	   	}else{
	   		if(current_child.nodeName=='js_data'){
	   			//document.location='http://helena4love.com/icms2/htdocs/archive/he/prog_search_search_simple_cmd_main';
	   			if (window.ActiveXObject){	
	   				eval(current_child.firstChild.nodeValue);
	   			}else{
   					fcs=current_child.firstChild;
   					 while(mytrim(fcs.nodeValue)=='' && fcs!=null && fcs!=undefined){	
	   					fcs=fcs.nextSibling;
   					 }
   					 if(fcs!=null && fcs!=undefined){
   					 	eval(fcs.nodeValue);
   					 }
   				}
	   		}else{
	   			if(current_child.nodeName=='return_value'){
	   				if (window.ActiveXObject){	
	   					return_value =eval(current_child.firstChild.nodeValue);
	   				}else{
	   					fcs=current_child.firstChild;
	   					 while(mytrim(fcs.nodeValue)=='' && fcs!=null && fcs!=undefined){	
		   					fcs=fcs.nextSibling;
	   					 }
	   					 if(fcs!=null && fcs!=undefined){
	   					 	return_value =eval(fcs.nodeValue);
	   					 }
	   				}
	   			}
	   		}
	   	}
	   	current_child=current_child.nextSibling;
	   }
	   return return_value;
	},
	mozilaSetAttribute:function (elmnt,attr,val){
		if(attr=='innerHTML'){
			elmnt.innerHTML=val;
			
		}
	},
	Submit:function (id,action,target){	
		if(isset($(id))){id=$(id)};
		if(!isset(id)){alert("no such id");return false;}
		var url="";
		if(action){
			url=action;
		}else{
			if(id.action!=null && id.action!=''){
				url=id.action;
			}else{
				alert('no action');return false;
			}
		}
		if(target!=null && target!=''){
			url+='&target='+target;
		}else{
			if(id.target!=null && id.target!=''){
				url+='&target='+id.target;
			}
		}
		url+='&'+this.FormToGet(id);
		this.Server(url);
		return false;
	},
	FormToGet:function(obj){
		var getstr = "";
	   var i;
	   for (i=0; i<obj.childNodes.length; i++) {   	
	   	//if(obj.childNodes[i].name=='undefined' || obj.childNodes[i].name=='' || obj.childNodes[i].name==null)continue;   	
	      if (obj.childNodes[i].tagName == "INPUT") {
	         if (obj.childNodes[i].type == "text" || obj.childNodes[i].type == "hidden" || obj.childNodes[i].type == "password") {
	            getstr += encodeURIComponent(obj.childNodes[i].name) + "=" + encodeURIComponent(obj.childNodes[i].value) + "&";
	         }
	         if (obj.childNodes[i].type == "checkbox") {
	            if (obj.childNodes[i].checked) {
	               getstr += encodeURIComponent(obj.childNodes[i].name) + "=" + encodeURIComponent(obj.childNodes[i].value) + "&";
	            } else {
	               // HTML not sending unchecked element!:
	               //getstr += obj.childNodes[i].name + "=&";
	            }
	         }
	         if (obj.childNodes[i].type == "radio") {
	            if (obj.childNodes[i].checked) {
	               getstr += encodeURIComponent(obj.childNodes[i].name) + "=" + encodeURIComponent(obj.childNodes[i].value) + "&";
	            }
	         }
	      }   else if (obj.childNodes[i].tagName == "SELECT") {
	      	var sel = obj.childNodes[i];
	      	//if(sel.type='select-one'){		         
		         getstr += encodeURIComponent(sel.name) + "=" + encodeURIComponent(sel.options[sel.selectedIndex].value) + "&";
	      	/*}else{
	      		for (var j=0; j<sel.options.length; j++) {
	            if (sel.options[j].selected) {
	            	getstr += encodeURIComponent(sel.name) + "=" + encodeURIComponent(sel.options[j].value) + "&";
	            }
	          }
	      	}*/
	      }  else if (obj.childNodes[i].tagName == "TEXTAREA") {
	         var sel = obj.childNodes[i];
	         getstr += encodeURIComponent(obj.childNodes[i].name) + "=" + encodeURIComponent(obj.childNodes[i].value) + "&";
	      } else {
	      	var elmnt=obj.childNodes[i];
	      	if(elmnt.childNodes.length && elmnt.childNodes.length>0 && elmnt.childNodes[0] && elmnt.childNodes[0].tagName!='undefined'){
	      			getstr +=this.FormToGet(elmnt);
	      	}
	      }
	      
	   }
	   return getstr;
	}
}

//Simplified XMLHttpRequest Connector
//constructor
function serverLoad(){
        this.browser = (window.XMLHttpRequest) ? 'mozilla' : 'ie';
    this.conname = (this.browser == 'mozilla') ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
}
//methods

function connectionResult(connection,target){
    switch(connection.readyState){
            case 0://
            //uninitialized
            //window.status ="serverLoad Request Status- Unknown";
            break;
            case 1:
            //loading 
            //window.status = "serverLoad Request Status- Loading";
            break;
            case 2:
            //loaded
            //window.status = "serverLoad Request Status- Loaded";
            break;
            case 3:
            //interactive state - whatever that means
            //window.status = 
//		alert("serverLoad Request Status- Interactive");
            break;
            case 4:
            	var ret=false;
            		ajax.numLoading--;
                 if (connection.status==200){ 
                         ret=ajax.XmlToHtml(connection);
                       if(ajax.numLoading==0){
                       	window.status='Done';
                       	         				
                       	
                       }else{
                       		window.status='Loading '+ajax.numLoading+' Object ...';
                       }
                 }else{
                         window.status='error on request';
                       if(ajax.numLoading==0){
                       		window.status='error on request';
                       }else{
                       		window.status='Loading '+ajax.numLoading+' Object, error on request' + (ajax.numLoading+1);
                       }
                 }
                 //clear connection
                 connection.abort();
                 this.conname=null;
                 return ret;
            break;
    }
};

//send and load
//param 1: url 
//param 2: "POST" "GET" 
//param 4: async
//param 5: to send - (xml or url encoded string)
//note: callback function should expect to receive the xmlhttprequest object
serverLoad.prototype.sendAndLoad = function(url, method, async,target,tosend){
        var connection = this.conname;
        if(!ajax.numLoading){
        		ajax.numLoading=0;
        }
        ajax.numLoading++;
        window.status='Loading '+ajax.numLoading+' Object ...';
       if(async){
	        this.conname.onreadystatechange = function(){
	        		connectionResult(connection,target);                
	        }
        }
        this.conname.open(method,url,async);
        if(tosend == undefined || tosend == null){
                var vars = null;        
        }else{
                var vars = tosend;
        }
        this.conname.send(vars);
        if(!async){
		return connectionResult(connection,target);
        }

};
//get object reference
serverLoad.prototype.getRef = function(){
   return this.conname;
};
//shortcut to responsetext
serverLoad.prototype.getResponseText = function(){
   return this.conname.responseText;
};
//shortcut to responseXML
serverLoad.prototype.getResponseXML = function(){
   return this.conname.responseXML;
};
//abort request
serverLoad.prototype.abortRequest = function(){
   this.conname.abort();
};




	function fixhomeheight(){
		var menuheight=$('menu').offsetHeight;
	
		if (isset($('in_newsbubble'))){
			var enews=$('homeside1').offsetHeight-$('in_newsbubble').offsetHeight;
			var enewssize=$('newsbubble').offsetHeight-$('in_newsbubble').offsetHeight;
		//		alert($('menu').offsetHeight);
		//	alert($('homeside1').offsetHeight);
			if (($('homeside1').offsetHeight) < $('menu').offsetHeight){
		
			$('in_newsbubble').style.height=$('menu').offsetHeight-enews-10 + 'px';
			}else{
				if(isset($('in_adbubble'))){
					var var1=menuheight-$('in_adbubble').offsetHeight;
					var var2=$('homeside1').offsetHeight-$('in_adbubble').offsetHeight;
					var sumvar=var2-var1;

				$('in_adbubble').style.height=sumvar+$('in_adbubble').offsetHeight-25 + 'px';
				
				}else{
					var var1=menuheight-$('in_menububble').offsetHeight;
					var var2=$('homeside1').offsetHeight-$('in_menububble').offsetHeight;
					var sumvar=var2-var1;
					
					$('in_menububble').style.height=sumvar+$('in_menububble').offsetHeight-15 + 'px';
				}
			}
		}

		
	}
	function pageloadfix(){

		fixhomeheight();
		
		if (isset($('homeside2'))){
				if ($('homeside2').offsetHeight < $('homeside1').offsetHeight){
			
					//if (isset($('bubble_big_add'))){	
					var var1=$('homeside2').offsetHeight-$('in_homesale').offsetHeight;
					var var2=$('homeside1').offsetHeight-$('in_homesale').offsetHeight;
					var sumvar=var2-var1;
					
					$('in_homesale').style.height=sumvar+$('in_homesale').offsetHeight-15 + 'px';
					//}
				}else{
					var enews=$('homeside1').offsetHeight-$('in_newsbubble').offsetHeight;
			$('in_newsbubble').style.height=$('homeside2').offsetHeight-enews-10 + 'px';
			
			fixhomeheight();
				}
		}
	}
	
		function showtab(idn){

		if(idn==1){
//setTimeout(function () {  document.getElementById('videoif').style.visibility='visible'; }, 300);
}else{
//setTimeout(function () {  document.getElementById('videoif').style.visibility='hidden'; }, 10);
}
		setTimeout(function () { 
		if ($('tab1').className=='cur'&&(idn!=1)){$('tab1').className='off';}
		if ($('tab2').className=='cur'&&(idn!=2)){$('tab2').className='off';}
		if ($('tab3').className=='cur'&&(idn!=3)){$('tab3').className='off';}
		if ($('tab4').className=='cur'&&(idn!=4)){$('tab4').className='off';}
		$('tab'+idn).className='cur';
		
			//setTimeout(function () {  document.getElementById('videoif').style.visibility='hidden'; }, 10);
		if ($('win1').style.display=='block'&&(idn!=1)){$('win1').style.display='none';}
		if ($('win2').style.display=='block'&&(idn!=2)){$('win2').style.display='none';}
		if ($('win3').style.display=='block'&&(idn!=3)){$('win3').style.display='none';}
		if ($('win4').style.display=='block'&&(idn!=4)){$('win4').style.display='none';}
		$('win'+idn).style.display='block';
	 }, 100);
	 return false
	}

function is_obj(element_id){
	return (isset($(element_id))) ? true : false;
}

function server(url,is_uncach,is_async){
	if((is_async == null) || (is_async == undefined))is_async = false;
	ajax.Server(url,false,is_async,is_uncach);
}

function do_submit(id,action,obj){
	//alert(obj);
	ajax.Submit(id,action);
	//obj.submit();
}

function wait_msg(roid,msg){
	if(!is_obj(roid))return;
	$(roid).innerHTML = '<h3>'+msg+'</h3>';
}

function includeJS(js_path){
	var js = document.createElement('script');
	js.type = 'text/javascript';
	js.src = js_path;
	js.defer = true;
	document.getElementsByTagName('head')[0].appendChild(js);
}
	