 function isempty(str) 
{
	atmp = str.split(String.fromCharCode(32));
	for (ii=0; ii< atmp.length;ii++ ) 
	{
		if (atmp[ii] != "") 
		return false;
	}	
	return true;
}
//---------------------------------------------
//Submit form by Javascript
//---------------------------------------------
function selfsubmit(straction) {
	window.document.forms[0].target = "_self";
	window.document.forms[0].action = straction;
	window.document.forms[0].submit();
}
//---------------------------------------------
//Check value for CheckBox
//---------------------------------------------
function setchecked(val,ctrChkName,content_div)
{
	
	$$('#'+content_div+' input').each(function(node){
											   
		if(node.id==ctrChkName)
		node.checked = val;
	})
	
 	
}
//---------------------------------------------
//Check value for CheckBox
//---------------------------------------------
function chkremove(ctrChkName) {
  fg = false;
  with (document.forms[0]) {
	 len = elements.length;
     for(var ii=0; ii<len; ii++) {
		if ((elements[ii].name == ctrChkName) && (elements[ii].checked)) {
			fg = true;
			break;
		}
	}
  }
  return(fg)
}
//--------------------------------------------------
// EmptyTextbox: Kiem tra textbox co rong hay khong
//--------------------------------------------------
function EmptyTextbox(FormName,TextboxName)
{
	x=document + "." + FormName + "." + TextboxName;
	if (x.value.length==0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

//---------------------------------------------------
// FocusField(fieldname)
//---------------------------------------------------
function FocusField(FieldName)
{
	window.document.form[0].FieldName.focus();
	//x.focus();
}

//---------------------------------------------------
// eMailCheck(str): Kiem tra dia chi email
//---------------------------------------------------
function eMailCheck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		  
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    
		    return false
		 }

 		 return true					
	}

//---------------------------------------------------
// IsNumeric: Kiem tra du lieu co phai So
//---------------------------------------------------
function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
//----------------------------------------------------
// GetDateTime: Lay ngay gio he thong:
// strCountry: VIE or ENG
//----------------------------------------------------

function GetDateTime(strCountry)
{
	var d=new Date()
	var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
	
	if(strCountry.toUpperCase() == "EN"){
		var weekday=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
		document.write(weekday[d.getDay()] + ",  ")
		document.write(d.getMonth() + 1 + " / ")
		document.write(d.getDate() + " / ")		
		document.write(d.getFullYear())
	}
	if(strCountry.toUpperCase() == "VI"){
		var weekday=new Array("Chủ nhật","Thứ Hai","Thứ Ba","Thứ Tư","Thứ Năm","Thứ Sáu","Thứ Bảy")
		document.write(weekday[d.getDay()] + ",  Ngày ")
		document.write(d.getDate() + " Tháng  ")
		document.write(d.getMonth() + 1 + " Năm  ")
		document.write(d.getFullYear() )
	}
	
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
/*ham kiem tra url hop le*/
function isValidURL(e)
{	var check = true
    //var re =/^www+\.[a-zA-Z0-9\-]+\.[a-zA-Z0-9-\.]+$/
	var re1 =/^http:+\/+\/+[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]/
	var re2 =/^http:+\/+\/www+\.[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]/
  //  if(re.test(e)==false)
		if(re1.test(e)==false)
			 if(re1.test(e)==false)
			 	check = false
	return check;
}

function check_anthorizenet() {
  var error = 0;
  var error_message = "Errors have occured.\n\n Please make the following corrections:\n\n";

    var cc_owner = document.frmpayment.txtcardowner.value;
   var cc_number = document.frmpayment.txtcard_number.value;
    
   if (cc_owner == "" || cc_owner.length < 3) {
      error_message = error_message + "* The owner's name of the credit card must be at least 3 characters.\n";
	alert(error_message);
    document.frmpayment.txtcardowner.focus();
	return false;
	  
    }
    if ( cc_number == "" || cc_number.length < 10 || !IsNumeric(cc_number)) {
      alert(error_message + "* The credit card number must be at least 10 characters.\n * OR must be numeric");
    document.frmpayment.txtcard_number.focus();
	return false;
    }
}

function check_paypal() {
	document.frmpayment.action="checkout_success.php?refer=payal&shippingto="+document.frmpayment.shipping_to.value+"&invoice="+document.frmpayment.invoice.value;
	document.frmpayment.submit();
}
function check_cc() {
  var error = 0;
  var error_message = "Errors have occured.\n\n Please make the following corrections:\n\n";

  var cc_owner = document.frmpayment.txtfullname.value;
  var cc_number = document.frmpayment.txtcard_number.value;
    
   if (cc_owner == "" || cc_owner.length < 3) {
      error_message = error_message + "* The owner's name of the credit card must be at least 3 characters.\n";
	alert(error_message);
    document.frmpayment.txtfullname.focus();
	return false;
	  
    }
    if ( cc_number == "" || cc_number.length < 10 || !IsNumeric(cc_number)) {
      alert(error_message + "* The credit card number must be at least 10 characters.\n * OR must be numeric");
    document.frmpayment.txtcard_number.focus();
	return false;
    }
//document.frmpayment.action="checkout_success.php?refer=cc&shippingto="+document.frmpayment.shipping_to.value+"&invoice="+document.frmpayment.invoice.value;
//document.frmpayment.valid.value="cc";
return true;
//document.frmpayment.submit();
}


function check_checkout()
{
		str = toRealCharCode(" Th&#244;ng b&#225;o l&#7895;i")+" \n ";
		str1 = str + toRealCharCode("Vui l&#242;ng nh&#7853;p H&#7885; & T&#234;n");
		str2 = str + toRealCharCode("&#272;&#7883;a ch&#7881; Email kh&#244;g &#273;&#250;ng");
		str3 = str + toRealCharCode("Vui l&#242;ng nh&#7853;p s&#7889; &#273;i&#7879;n tho&#7841;i HO&#7862;C s&#7889; &#273;i&#234;n tho&#7841;i kh&#244;ng &#273;&#250;ng");
		str4 = str + toRealCharCode("Vui l&#242;ng nh&#7853;p T&#7881;nh/Th&#224;nh Ph&#7889;");
		str5 = str + toRealCharCode("Vui l&#242;ng ch&#7885;n Qu&#7889;c gia");
		str6 = str + toRealCharCode("Vui l&#242;ng  ch&#7885;n Bang/T&#7881;nh/Th&#224;nh ph&#7889;");
		str7 = str + toRealCharCode("B&#7841;n ph&#7843;i &#272;&#7891;ng &#253; c&#225;c &#273;i&#7873;u kho&#7843;n s&#7917; d&#7909;ng c&#7911;a ch&#250;ng t&#244;i b&#7857;ng c&#225;ch checked v&#7843;o &#244; &#273;&#7891;ng &#253; &#273;i&#7873;u kho&#7843;n s&#7917; d&#7909;ng");
		str8 =str + toRealCharCode("Vui l&#242;ng nh&#7853;p &#273;&#7883;a ch&#7881;");
	if(document.frmcheckout.txtfullname.value==""){
		alert(str1);
		document.frmcheckout.txtfullname.focus();
		return false;
	}
	if(!eMailCheck(document.frmcheckout.txtemail.value))
	{
		alert(str2);
		document.frmcheckout.txtemail.focus();
		return false;
	}
	if(document.frmcheckout.txtaddress.value==""){
		alert(str8);
		document.frmcheckout.txtaddress.focus();
		return false;
	} 
	if(document.frmcheckout.txtphone.value=="" || !IsNumeric(document.frmcheckout.txtphone.value)){
		alert(str3);
		document.frmcheckout.txtphone.focus();
		return false;
	} 

	if(document.frmcheckout.txtprovince.value==""){
		alert(str4);
		document.frmcheckout.txtprovince.focus();
		return false;
	} 
	if(document.frmcheckout.txtcountry.value==""){
		alert(str5);
		document.frmcheckout.txtcountry.focus();
		return false;
	}
	if(document.frmcheckout.txtstate.value==""){
		alert(str6);
		document.frmcheckout.txtstate.focus();
		return false;
	}
	if(!document.frmcheckout.agreement.checked){
		alert(str7);
		document.frmcheckout.agreement.focus();
		return false;
	}	
	document.frmcheckout.act.value="order";
	document.frmcheckout.action ="payment.php";
	document.frmcheckout.submit();
return true;
}


function check(style)
{
	if(style =="tracking")
	 {
		if(document.frmtracking.txttracking.value=="")
		 { alert("Error. \n You must input your invoice for tracking status.");
		 document.frmtracking.txttracking.focus();
		  return false
		 }
		 document.frmtracking.action="?cfm=_invoice&_actid=invoice_3&invoice=&invoice="+document.frmtracking.txttracking.value;
	 }

if(style ==12)
	 {
		if(document.frm.txtkeyseach.value=="")
		 { alert("You must type keyword");
		 document.frm.txtkeyseach.focus();
		  return false
		 }
		 else
		 { 
		  document.frm.action="result_search.php?server=&key="+document.frm.txtkeyseach.value+"&category=";	 
	 	  document.frm.submit()
		 }
	 }

		if(style ==13)
		 {
			//alert("hay qua"+ document.frm.btsearch.value);
			if(document.frm.txtemail.value!="")
			 { 
				document.frm.action="newsletter.php?email="+document.frm.txtemail.value;	 
				document.frm.submit()
			  }
			 else
				{ 
  				 alert("You must type Email for sign up newsletter");
				 document.frm.txtemail.focus();
				return false
				}
		 }
 		if(style ==14)
		 {
				var strID="";
					with (document.frm)
					{
						len = elements.length;
						for(var ii=0; ii<len; ii++)
						{	
							if (elements[ii].name == "vote") 
								if (elements[ii].checked)
									strID = elements[ii].value;
						}//end for
						
					}//end with
					if(strID=="") 
					{
					 alert("Please check for poll."); 
					 return false;
					}
				 document.frm.action='resultvote.php?option='+strID;	
				 document.frm.submit()
		 }
}

function getID(mode){
	var strID="";
	with (document.frmAddshop)
	{
		len = elements.length;
		for(var ii=0; ii<len; ii++)
		{	
			if (elements[ii].name == "chkid[]") 
				if (elements[ii].checked)
					strID = strID + elements[ii].value+mode;
		}//end for
	}//end with
	return strID;
}
function checkAddcart(proid)
{	
	str2 = "Errors have occured.\n Please select at least item to add cart";  
	strID=""
	strID=getID("*");
	if (strID != "")
	{

			//frmAddshop.act.value="13";
			frmAddshop.action="shopcart.php?server=&qty=false&act=add&valid=false&pid="+proid;
			frmAddshop.submit();
	}
	else 
	alert(str2);
}
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

function OpenWin(URLStr, width, height)
{

  if(popUpWin)

  {

    if(!popUpWin.closed) popUpWin.close();

  }
var left = (screen.width-width)/2;
var top = (screen.height-height)/2;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');

}

// convert to NCR - UTF8
function  toRealCharCode(str1) 
{
 var c0
 var str2='' ;
 var strx=''
 var idx
 
  idx = str1.indexOf('&')
  if( idx<0 ) return str1

 var i = 0
 while ( i < str1.length )
  {
    c0 = str1.substring(i,i+1)
    i++
    if( c0 != '&' ) continue

    strx  += str1.substring(0,i-1)
    str1 = str1.substring(i-1,str1.length)
    idx = str1.indexOf(';')
    if(idx <0 ) break;
  
    str2 = str1.substring(1,idx)
    
	//2001/03/26 Bo sung them phan nhan biet cac ky tu web (31 ky tu)
	//Cac ky tu co code < 255 khong duoc IE luu duoi dang &#xxx; ma duoi dang &abc;, do do phai chu y den ngoai le nay !!!
	if (str2=='aacute') str2='225' //a'
	else if (str2=='agrave') str2='224' //a`
	else if (str2=='atilde') str2='227'  //a~
	else if (str2=='Aacute') str2='193'  //A'
	else if (str2=='Agrave') str2='192'  //A`
	else if (str2=='Atilde') str2='195'  //A~

	else if (str2=='acirc') str2='226'  //a^
	else if (str2=='Acirc') str2='194'  //A^

	else if (str2=='eacute') str2='233'  //e'
	else if (str2=='egrave') str2='232'  //e`
	else if (str2=='Eacute') str2='201'  //e'
	else if (str2=='Egrave') str2='200'  //e`

	else if (str2=='ecirc') str2='234'  //e^
	else if (str2=='Ecirc') str2='202'  //E^ 

	else if (str2=='iacute') str2='237'  //i'
	else if (str2=='igrave') str2='236'  //i`
	else if (str2=='Iacute') str2='205'  //I'
	else if (str2=='Igrave') str2='204'  //I`

	else if (str2=='oacute') str2='243'  //o'
	else if (str2=='ograve') str2='242'  //o`
	else if (str2=='otilde') str2='245'  //o~
	else if (str2=='Oacute') str2='243'  //O'
	else if (str2=='Ograve') str2='242'  //O`
	else if (str2=='Otilde') str2='245'  //O~

	else if (str2=='ocirc') str2='244'  //o^
	else if (str2=='Ocirc') str2='212'  //O^

	else if (str2=='uacute') str2='250'  //u'
	else if (str2=='ugrave') str2='249'  //u`
	else if (str2=='Uacute') str2='218'  //U'
	else if (str2=='Ugrave') str2='217'  //U`

	else if (str2=='yacute') str2='253'  //y'
	else if (str2=='Yacute') str2='221' //Y'

	else str2=str2.substring(1,str2.length);

	str1 = str1.substring(idx+1,str1.length)

    strx += String.fromCharCode(str2)
    i = 0
  }

 return strx+str1 ;

}

// Convert to UTF-8 sang JP 16 bit
  function  toWebUnicode( str1 ) {
	var code
	var str2 =''
	var len = str1.length
	for(var i=0 ; i<len; i++) {
	  code = str1.charCodeAt(i) ;
	  if (code < 128) continue ;
	  //Chi xu ly cac ky tu tieng Viet
	  //if  ((code >= 192 && code <= 511) || (code >= 7808 && code <= 7929) )
	  //{
	  str2 += str1.substring(0,i) + '%26%23' + code + ';'
	  str1 = str1.substring(i+1,str1.length)
	  len = str1.length
	  i=0
	  //}
	  //else {continue;}

	}
	str1 = str2+str1

	// Once more time
	str2 =''
	len = str1.length
	for(var i=0 ; i<len; i++) {
	  code = str1.charCodeAt(i) ;
	  if(code<128) continue ;
	  str2 += str1.substring(0,i) + '%26%23' + code + ';'
	  str1 = str1.substring(i+1,str1.length)
	  len = str1.length
	  i=0
	}

	str1 = str2+str1

	return str1 ;
  }	  

function checkvote(){
	var strID="";
	with (document.frmvote)
	{
		len = elements.length;
		for(var ii=0; ii<len; ii++)
		{	
			if (elements[ii].name == "vote") 
				if (elements[ii].checked)
					strID = elements[ii].value;
		}//end fo
		
	}//end with
	if(strID=="") 
	{
	 alert("Ban phai binh chon moi duoc xem ket qua./ You must poll before view resulf"); 
	 return false;
	}
 document.frmvote.action='resultvote.php?option='+strID;	
 return true;
}

 function m_over(divID)
{
	document.getElementById(divID).className ="rowxam";
}
function m_out(divID)
{

	document.getElementById(divID).className ="rows";
}


function getID(mode){
	var strID="";
	with (document.forms[0])
	{
		len = elements.length;
		for(var ii=0; ii<len; ii++)
		{	
			if (elements[ii].name == "chkid[]") 
				if (elements[ii].checked)
					strID = strID + elements[ii].value+mode;
		}//end for
	}//end with
	return strID;
}
function getChecked(action)
{	
	strID=""
	strID=getID("*");
	if (strID != "")
	{
		var SayYes = confirm("Cac doi tuong ban chon se bi xoa");
		if (SayYes == true){
			document.forms[0].action=action;
			document.forms[0].submit();
		}
	}
	else 
	alert("Ban phai chon doi tuong de thuc hien");
}
function showbox(mode){
	//document.getElementById('search_d').style.display ="none";
	//document.getElementById('search_n').style.display ="block";
	//document.getElementById('idsearch_result').style.display ="none";
	//document.getElementById('boxsearch').value ="0";
	//mode=document.getElementById('idboxsearch').value;
	//alert(mode)
	if(mode=="1"){
		//document.getElementById('search_d').style.display ="none";
		document.getElementById('boxfilter').style.display ="block";
		document.getElementById('idboxsearch').value =0;
		document.getElementById('idsearch_result').style.display ="block";
		//alert(mode);
		//alert("1:"+mode); return ;
	}
	if(mode=="0"){
		//document.getElementById('search_d').style.display ="block";
		document.getElementById('boxfilter').style.display ="none";
		document.getElementById('idboxsearch').value =1;
		document.getElementById('idsearch_result').style.display ="none";
		//alert("0:"+mode); return ;
	}
	
	//alert(document.getElementById('boxsearch').value)
}
/////////////////////////////////////////////////////////
///Seeacr view billing
function search_code_billing(pathurl,code){
		location.href=pathurl+""+code;
}
function getCheckedEdit(action)
{	
	strID=""
	strID=getID("*");
	if (strID != "")
	{
		//var SayYes = confirm("Cac doi tuong ban chon se bi xoa");
		//if (SayYes == true){
			document.forms[0].action=action;
			document.forms[0].submit();
		//}
	}
	else 
	alert("Ban phai chon doi tuong de thuc hien");
}
///////////////////////////////////////////////////////////////
function FormatCurrency(objNum)
   {
	   
        var num = objNum.value.replace('$','');
        var ent, dec, dot;
		
        if (num != '' && num != objNum.oldvalue)
        {
             num = MoneyToNumber(num);
             if (!isNaN(num))
             {
                  var ev = (navigator.appName.indexOf('Netscape') != -1)?Event:event;
            ent = num.split('.')[0];
            dec = num.split('.')[1];
            if (dec || ev.keyCode == 190)
            {
                 dot = '.';
                 if (dec.toString().length > 2) dec = dec.toString().substr(0,2);
            }
            else
            {
                 dec = '';
              dot = '';
            }
                  objNum.value = AddCommas(ent) + dot + dec;
                  objNum.oldvalue = objNum.value;

             }
          objNum.value = objNum.oldvalue;
        }
   }
   
 function MoneyToNumber(num)
   {
        return (num.replace(/,/g, ''));
 
   }

    function AddCommas(num)
   {
        numArr=new String(num).split('').reverse();
        for (i=2;i<numArr.length;i+=3)
        {
             numArr[i]+=',';
        }
        return numArr.reverse().join('');
   }
 
  function number_onblur(objNum)
  {
       var num = objNum.oldvalue;
    if (num.charAt(num.toString().length-1) == '.') num = num.replace('.','');
    objNum.value = "$" + num;
  }	
  
///////////////////
/* Dinh dang so cho du lieu thuoc tai chinh */
  function convert(field){
    var strk=field.value;
    str=clearDot(strk);
    var stmp="";
    if (str!=""){
        var l=str.length-1;
        k=0;
        for (i=l;i>=0;i--){
           k++;
           stmp= str.substr(i,1) + stmp;
           if (str.substr(i,1)==","){
             k=0;
//                  return stmp;
          }
          if ((k==3)&&(i>0)){
              k=0;
            stmp= "." + stmp;
          }
        }
     }
   field.value=stmp;
  }
/************************************************/
    function clearDot(st){
        var stmp="";
        if (st!=""){
           var l=st.length;
           for (i=0;i<l;i++){
              if ((st.substr(i,1)!=".")&&(st.substr(i,1)!="-")&&(!isNaN(st.substr(i,1))))
               stmp= stmp+st.substr(i,1);
           }
        }
      return stmp;
    }
/************************************************/
    function replace(target,oldTerm,newTerm) {
           var work = target;
           var ind = 0;
           var next = 0;
           while ((ind = work.indexOf(oldTerm,next)) >= 0) {
             target = target.substring(0,ind) + newTerm + target.substring(ind+oldTerm.length,target.length);
             work = work.substring(0,ind) + newTerm + work.substring(ind+oldTerm.length,work.length);
             next = ind + newTerm.length;
             if (next >= work.length) { break; }
           }
           return target;
    }
/****************************************/

function slide_searchbox(namediv){
	
	if(optionflag_search)
	{
		//alert("1:"+optionflag_search)
		Effect.SlideDown(namediv, {duration: 1.0});
		optionflag_search=false;
	}
	else
	{
		//alert("2:"+optionflag_search)
		Effect.SlideUp(namediv, {duration: 1.0});
		optionflag_search=true;
	
	
	
	}
}
/****************************************/
//Dialog

function overlay(url_page)
{

var arrayPageSize = getPageSize();
$('overlay_content').style.width=arrayPageSize[0] + 'px';
$('overlay_content').style.height=arrayPageSize[1] + 'px';
$('overlay').style.width=arrayPageSize[0] + 'px';
$('overlay').style.height=arrayPageSize[1] + 'px';


if($('overlay_content').style.visibility=="visible"){
		$$('select', 'object', 'embed').each(function(node){
	node.style.visibility = "visible";
		})
;
	
		$('overlay_content').style.visibility= "hidden";
		$('overlay').style.visibility= "hidden";
		
		$$('#overlay_content select,object,embed').each(function(tab_s){
			tab_s.style.visibility = "hidden";
		});
		
		$$('#overlay_content iframe').each(function(iframe){
			iframe.dispose();

		});
		
		
		//$$('#overlay select').style.visibility= "hidden";
}else{
	$$('select', 'object', 'embed').each(function(node){
	node.style.visibility = "hidden";
		})
	$('overlay_content').style.visibility= "visible";
	$('overlay').style.visibility= "visible";
	
	$$('#overlay_content select,object,embed').each(function(tab_s){
			tab_s.style.visibility = "visible";
		});
	//////////////////////
	var myIFrame =  new Element('iframe', {//			
			'src':url_page,
			'id':'myiframe',
			'name':'myiframe',
			'frameborder': '0', 'marginheight': '0', 'marginwidth': '0'//'scrolling': 'no',
		}).injectInside('overlay_content2','bottom');
	
	//alert((arrayPageSize[1]-80)+ 'px')
	//var myFirstElement  = new Element('div', {id: 'myFirstElement'});

	//$('overlay_content').adopt(myFirstElement);

 	//$('overlay_content').adopt(myIFrame);
	/*$$('#overlay_content div').each(function(content){
			content.adopt(myIFrame);
			//alert(content.style.height)

			
	});*/
	
	/*$$('#overlay_content iframe').each(function(frame_page){
			frame_page.style.height=(arrayPageSize[1]-80) + 'px';

	});*/
	
	

}



}
/////////////////////////////////
function getPageSize(){
	 var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		return [pageWidth,pageHeight];
		//return pageHeight;
}
//////////////////////////////////////
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}
 
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
//////////////////////////////////////

