basehref = function(){return document.getElementsByTagName('base')[0].href;}

if (!window.ORORI) {
  ORORI = {};
}
// Only load if this class is not already loaded
if (!ORORI.Bootstrap) {
 ORORI.Bootstrap = {
		ensureInit:function(callback){
			try{
				return eval(callback+'()');
			}catch(err){
				setTimeout(function(){ORORI.ensureInit(callback)}, 500);
			}
		}
	}
 window.ORORI.ensureInit=ORORI.Bootstrap.ensureInit; 
}

function fbs_click(u,t) {
	var fbwin = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	fbwin.focus();
	return false;
}
function format(input){
var num = input.value.replace(/\./g,'');
 if(!isNaN(num)){
     num = num.toString().split('').reverse().join('').replace(/(?=\d*\.?)(\d{3})/g,'$1.');
     num = num.split('').reverse().join('').replace(/^[\.]/,'');
     input.value = num;
 }

 else{ alert('You may enter only numbers in this field!');
       input.value = input.value.replace(/[^\d\.]*/g,'');
 }  
}
function keepTrying(func){
	try{
		if (document.attempt==undefined)document.attempt=1;else document.attempt++;
		func();
	}catch(ex){
		$('monitor').innerHTML='attempt number '+document.attempt;
		setTimeout(function(){keepTrying(func)}, 2000);
	}
}
function loadCSS(link_href){
	var oLink = document.createElement("link");
	oLink.href = link_href;
	oLink.rel = "stylesheet";
	oLink.type = "text/css";
	document.getElementsByTagName("HEAD")[0].appendChild(oLink);
}
function loadScript(script_src){
	var oScript = document.createElement("script");
	oScript.src= script_src;
	oScript.type = "text/javascript";
	document.getElementsByTagName("HEAD")[0].appendChild(oScript);
}
function checkemail(email) {
    var str =email;
    str = str.toLowerCase( );
    if (str.indexOf("@") > 1) {
        var addr = str.substring(0, str.indexOf("@"));
        var domain = str.substring(str.indexOf("@") + 1, str.length);
        if (domain.indexOf(".") == -1) {
           // alert("Verify the domain portion of the email address.");
            return false;
        }

        for (var i = 0; i < addr.length; i++) {
            oneChar = addr.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46))  || 
                (i == addr.length - 1 && oneChar == 46)) {
               // alert("Verify the user name portion of the email address.");
                return false;
            }
			
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                //alert("Verify the user name portion of the email address.");
                return false;
            }
        }
        for (i = 0; i < domain.length; i++) {
            oneChar = domain.charAt(i).charCodeAt(0);
            if ((i == 0 && (oneChar == 45 || oneChar == 46)) || 
                ((i == domain.length - 1  || i == domain.length - 2) && oneChar == 46)) {
                //alert("Verify the domain portion of the email address.");
                return false;
            }
            if (oneChar == 45 || oneChar == 46 || oneChar == 95 || 
                (oneChar > 47 && oneChar < 58) || (oneChar > 96 && oneChar < 123)) {
                continue;
            } else {
                return false;
            }
        }
        return true;
    }
    return false;
}
function appearAgain(item){
	$(item).style.display='block';
	new Fx.Style(item, 'opacity').start(0,1);
}
function flashAndAway(item){
	new Fx.Style(item, 'opacity').start(1,0).chain(function(){$(item).style.display='none';});
}
function flashError(){
	new Fx.Style('errorFlash', 'opacity').start(1,0).chain(function(){$('errorFlash').style.display='none';});
}
function viewLoading(div){
	divObj = $(div);
	img = new Element('img', {'src': 'images/loading.gif', 'styles': {'position':'absolute', 'width': 32, 'height': 32, 'left':'50%','top':'50%', 'marginLeft':'-16px', 'marginTop':'-16px', 'display':'block'}}).injectInside(divObj);
}
function closeLoading(div){
	divObj = $(div);
	img = divObj.getElementsByTagName('img');
	for(i=0;i<img.length;i++){
		if(img[i].src.indexOf('images/loading.gif')!=-1){img[i].setStyle('display', 'none');}
	}
}
function changeLink(div,link_order,link_href){
	if((x=$(div))!=null){
		anchor=x.getElementsByTagName('a');
		if(a=anchor[link_order]){a.href=http_server_link+link_href;}
	}
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}
if(typeof(showSelectBoxes)!='function'){
	function showSelectBoxes(){var selects=document.getElementsByTagName("select");for(i=0;i!=selects.length;i++){selects[i].style.visibility="visible";}}
}
if(typeof(hideSelectBoxes)!='function'){
	function hideSelectBoxes(){var selects=document.getElementsByTagName("select");for(i=0;i!=selects.length;i++){selects[i].style.visibility="hidden";}}
}
function _onmouseover(obj){
	img=obj.getElementsByTagName('img');
	img[0].style.display='none';
	img[1].style.display='block';
}
function _onmouseout(obj){
	img=obj.getElementsByTagName('img');
	img[0].style.display='block';
	img[1].style.display='none';
}
var fixPNG_arVersion = navigator.appVersion.split("MSIE")
var fixPNG_version = parseFloat(fixPNG_arVersion[1])
function fixPNG(myImage) 
{
    //return false;
	if ((fixPNG_version >= 5.5) && (fixPNG_version < 7) && (document.body.filters)) 
    {
       var imgID = (myImage.id) ? "id='" + myImage.id + "' " : ""
	   var imgClass = (myImage.className) ? "class='" + myImage.className + "' " : ""
	   var imgTitle = (myImage.title) ? 
		             "title='" + myImage.title  + "' " : "title='" + myImage.alt + "' "
	   var imgStyle = "display:inline-block;" + myImage.style.cssText
	   var strNewHTML = "<span " + imgID + imgClass + imgTitle
                  + " style=\"" + "width:" + myImage.width 
                  + "px; height:" + myImage.height 
                  + "px;" + imgStyle + ";"
                  + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
                  + "(src=\'" + myImage.src + "\', sizingMethod='scale');\"></span>"
	   myImage.outerHTML = strNewHTML	  
    }
}
function CheckDateRange(from, to){if(Date.parse(from.value)<= Date.parse(to.value)){return true;}else{return false;}}
function IsValidDate(DateToCheck, FormatString) {
  var strDateToCheck;
  var strDateToCheckArray;
  var strFormatArray;
  var strFormatString;
  var strDay;
  var strMonth;
  var strYear;
  var intday;
  var intMonth;
  var intYear;
  var intDateSeparatorIdx = -1;
  var intFormatSeparatorIdx = -1;
  var strSeparatorArray = new Array("-"," ","/",".");
  var strMonthArray = new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");
  var intDaysArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

  strDateToCheck = DateToCheck.toLowerCase();
  strFormatString = FormatString.toLowerCase();
  
  if (strDateToCheck.length != strFormatString.length) {
    return false;
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strFormatString.indexOf(strSeparatorArray[i]) != -1) {
      intFormatSeparatorIdx = i;
      break;
    }
  }

  for (i=0; i<strSeparatorArray.length; i++) {
    if (strDateToCheck.indexOf(strSeparatorArray[i]) != -1) {
      intDateSeparatorIdx = i;
      break;
    }
  }

  if (intDateSeparatorIdx != intFormatSeparatorIdx) {
    return false;
  }

  if (intDateSeparatorIdx != -1) {
    strFormatArray = strFormatString.split(strSeparatorArray[intFormatSeparatorIdx]);
    if (strFormatArray.length != 3) {
      return false;
    }

    strDateToCheckArray = strDateToCheck.split(strSeparatorArray[intDateSeparatorIdx]);
    if (strDateToCheckArray.length != 3) {
      return false;
    }

    for (i=0; i<strFormatArray.length; i++) {
      if (strFormatArray[i] == 'mm' || strFormatArray[i] == 'mmm') {
        strMonth = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'dd') {
        strDay = strDateToCheckArray[i];
      }

      if (strFormatArray[i] == 'yyyy') {
        strYear = strDateToCheckArray[i];
      }
    }
  } else {
    if (FormatString.length > 7) {
      if (strFormatString.indexOf('mmm') == -1) {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mm'), 2);
      } else {
        strMonth = strDateToCheck.substring(strFormatString.indexOf('mmm'), 3);
      }

      strDay = strDateToCheck.substring(strFormatString.indexOf('dd'), 2);
      strYear = strDateToCheck.substring(strFormatString.indexOf('yyyy'), 2);
    } else {
      return false;
    }
  }

  if (strYear.length != 4) {
    return false;
  }

  intday = parseInt(strDay, 10);
  if (isNaN(intday)) {
    return false;
  }
  if (intday < 1) {
    return false;
  }

  intMonth = parseInt(strMonth, 10);
  if (isNaN(intMonth)) {
    for (i=0; i<strMonthArray.length; i++) {
      if (strMonth == strMonthArray[i]) {
        intMonth = i+1;
        break;
      }
    }
    if (isNaN(intMonth)) {
      return false;
    }
  }
  if (intMonth > 12 || intMonth < 1) {
    return false;
  }

  intYear = parseInt(strYear, 10);
  if (isNaN(intYear)) {
    return false;
  }
  if (IsLeapYear(intYear) == true) {
    intDaysArray[1] = 29;
  }

  if (intday > intDaysArray[intMonth - 1]) {
    return false;
  }
  
  return true;
}

function IsLeapYear(intYear) {
  if (intYear % 100 == 0) {
    if (intYear % 400 == 0) {
      return true;
    }
  } else {
    if ((intYear % 4) == 0) {
      return true;
    }
  }

  return false;
}
function getTop(myObj)
{
	var top = 0;
	if (myObj.offsetParent) {
		top = myObj.offsetTop;
		while (myObj = myObj.offsetParent) {
			top += myObj.offsetTop;
		}
	}
	return top;
}
function getLeft(myObj)
{
 	var left = 0;
	if (myObj.offsetParent) {
		left = myObj.offsetLeft;
		while (myObj = myObj.offsetParent) {
			left += myObj.offsetLeft
		}
	}
	return left;
}
function showMenu(divID,imgID,imgHover,offset)
{
	if(offset==undefined){offset=10;}
	if((x=findObj(imgID))!=null){
		if(document.SrSignature==undefined || document.SrSignature==''){document.SrSignature=x.src;}
		x.src=imgHover;
		posX = getLeft(x);
		posY = getTop(x)+offset;
	}
	if((x=findObj(divID))!=null){
		x.style.left = posX +'px';
		x.style.top = posY +'px';
		x.style.display='block';
	}
}
function hideMenu(divID,imgID)
{
	if((x=findObj(divID))!=null){x.style.display='none';}
	//if ((x=findObj(imgID))!=null){x.src=document.SrSignature;}
}
function swapImgRestore(){var i,x,a=document.sr;for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;if ((x=findObj('imgTeks'))!=null){x.src=document.textImg}}function findObj(n,d){var p,i,x;if(!d) d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n];for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n);return x;}function swapImage(){var i,j=0,x,a=swapImage.arguments;document.sr=new Array;for(i=0;i<(a.length-2);i+=3)if ((x=findObj(a[i]))!=null){document.sr[j++]=x;if(!x.oSrc)x.oSrc=x.src; x.src=a[i+2];}if ((x=findObj('imgTeks'))!=null){document.textImg=x.src;x.src=a[3]}}
function MM_preloadImages(){var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments;for(i=0;i<a.length;i++)if(a[i].indexOf("#")!=0){d.MM_p[j]=new Image;d.MM_p[j++].src=a[i];}}}function MM_swapImgRestore(){var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_findObj(n,d){var p,i,x;if(!d)d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all)x=d.all[n];for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x && d.getElementById) x=d.getElementById(n);return x;}function MM_swapImage(){var i,j=0,x,a=MM_swapImage.arguments;document.MM_sr=new Array;for(i=0;i<(a.length-2);i+=3)if((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;if(!x.oSrc)x.oSrc=x.src;x.src=a[i+2];}}function overview_show(section){for(i=0;i<overview_section.length;i++){if ((x=MM_findObj(overview_section[i]))!=null){x.style.display='none';}}if((x=MM_findObj(section))!=null){x.style.display='block';}}
function pop_modify_tab(){if(td_modify.style.display=="none"){td_modify.style.display="";img_modify_btn.src="images/btn_modify_ring_grey.gif";img_add_btn.src="images/spacer.gif";}else{td_modify.style.display="none";img_modify_btn.src="images/btn_modify_ring.gif";img_add_btn.src="images/btn_add_item.gif";}}
function getObject(obj) {
  var theObj;
  if(document.all) {
    if(typeof obj=="string") {
      return document.all(obj);
    } else {
      return obj.style;
    }
  }
  if(document.getElementById) {
    if(typeof obj=="string") {
      return document.getElementById(obj);
    } else {
      return obj.style;
    }
  }
  return null;
}
function charCounter(txtBox,spanID,msg,maxChar) {
  var txtBoxObj=getObject(txtBox);
  var spanIDObj=getObject(spanID);
  var lenChar=maxChar - txtBoxObj.value.length;
  if(lenChar <= 0) {
    lenChar=0;
    msg='<span class="disable"> '+msg+' </span>';
    txtBoxObj.value=txtBoxObj.value.substr(0,maxChar);
  }
  spanIDObj.innerHTML = msg.replace("{CHAR}",lenChar);
}
function createRequestObject(){
	var request_o;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		request_o = new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		request_o = new XMLHttpRequest();
	}
	return request_o;
}
var fileLoadingImage = "images/loading.gif";
var fileLoadingImageHeight = 32;
function getContent(url,divID){
	/* The variable http will hold our new XMLHttpRequest object. */
	var divContainer="";
	var redirect_url="";	
	divContainer = divID;
	//document.getElementById(divContainer).style.height= fileLoadingImageHeight + 'px';
	if((x=MM_findObj(divContainer))!=null){
		img = new Element('img', {'src': 'images/loading.gif', 'styles': {'position':'absolute', 'width': 32, 'height': 32, 'left':'50%','top':'50%', 'marginLeft':'-16px', 'marginTop':'-16px'}}).injectInside(x);
		//x.innerHTML +='<div style="position:absolute;left:50%;top:50%;z-index:2;margin-left:-' + (fileLoadingImageHeight/2) + 'px;margin-top:-' + (fileLoadingImageHeight/2) + 'px;display:block;"><img src="' + fileLoadingImage + '" ></div>';
	}else{
		//setTimeout(function(){getContent(url,divID);});
	}
	var http = createRequestObject(); 	
	var queryStr="";

	a = getContent.arguments;	
	for(i=2;i<a.length;i++)
	{
		if(i==(a.length-1)) queryStr = queryStr + a[i];else queryStr = queryStr + a[i] + '&';
	}
	//alert(escape(queryStr).replace('%3D','='));
	//document.write(url + '?' + queryStr);
	//queryStr=escape(queryStr).replace(/\%3D/g,'=').replace(/\%26/g,'&').replace(/\%7B/g,'{').replace(/\%7D/g,'}');
	if(url.indexOf('?')==-1){http.open('post', url + '?' + queryStr);}else{http.open('post', url + '&' + queryStr);}
	
	/* Define a function to call once a response has been received.  */
	http.onreadystatechange = function(){
			/* Make sure that the transaction has finished. The XMLHttpRequest object 
			has a property called readyState with several states:
			0: Uninitialized
			1: Loading
			2: Loaded
			3: Interactive
			4: Finished */
		if(http.readyState == 1){
			//document.getElementById(divContainer).innerHTML = "Loading";
		}
		if(http.readyState == 4 && http.status == 200){ //Finished loading the response
			/* We have got the response from the server-side script,
				let's see just what it was. using the responseText property of 
				the XMLHttpRequest object. */
			var response = http.responseText;
			/* And now we want to change the product_categories <div> content.
				we do this using an ability to get/change the content of a page element 
				that we can find: innerHTML. */
			
			if(url.indexOf('create_account_content.php')>-1 && queryStr.indexOf('action')>-1){
				//document.write('url'+url+',query'+queryStr);
			}
			if(response.toString().indexOf('http://')==0 || response.toString().indexOf('https://')==0){
			document.write('<script language=javascript>window.location.href=\''+ response +'\'</script>')
			http.send(null);
			}
			if((x=MM_findObj(divContainer))!=null){
			x.innerHTML = response;}
			Lightbox.refresh();
			in_progress = false;
		}		
	} 
	/* Send the data.  */
	http.send(null);
}
function postContent(url,divID){
	/* The variable http will hold our new XMLHttpRequest object. */
	var divContainer="";
	var redirect_url="";
	var queryStr="";
	divContainer = divID;
	if((x=MM_findObj(divContainer))!=null){
		img = new Element('img', {'src': 'images/loading.gif', 'styles': {'position':'absolute', 'width': 32, 'height': 32, 'left':'50%','top':'50%', 'marginLeft':'-16px', 'marginTop':'-16px'}}).injectInside(x);
	}

	var http = createRequestObject(); 
	a = postContent.arguments;	
	for(i=2;i<a.length;i++)
	{
		if(i==(a.length-1)) queryStr = queryStr + a[i];else queryStr = queryStr + a[i] + '&';
	}

	http.open('POST', url, true);
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
	http.setRequestHeader("Content-length", queryStr.length);
	http.setRequestHeader("Connection", "Keep-Alive");
	http.send(queryStr);

	/* Define a function to call once a response has been received.  */
	http.onreadystatechange = function(){
			/* Make sure that the transaction has finished. The XMLHttpRequest object 
			has a property called readyState with several states:
			0: Uninitialized
			1: Loading
			2: Loaded
			3: Interactive
			4: Finished */
		if(http.readyState == 1){
			//document.getElementById(divContainer).innerHTML = "Loading";
		}
		
		if(http.readyState == 4 && http.status == 200){ //Finished loading the response
			/* We have got the response from the server-side script,
				let's see just what it was. using the responseText property of 
				the XMLHttpRequest object. */
			var response = http.responseText;
			/* And now we want to change the product_categories <div> content.
				we do this using an ability to get/change the content of a page element 
				that we can find: innerHTML. */
			if(response.toString().indexOf('http://')==0||response.toString().indexOf('https://')==0){
			document.write('<script language=javascript>window.location.href=\''+ response +'\'</script>')
			http.send(null);
			}
			if((x=MM_findObj(divContainer))!=null){
			x.innerHTML = response;
			}
			Lightbox.refresh();
			in_progress = false;

			
		}		
	} 
}
String.prototype.trim = function(){return( this.replace(/^\s*([\s\S]*\S+)\s*$|^\s*$/,'$1') );}
function MM_swapTitle() { //v3.0
  var i,j=0,x,a=MM_swapTitle.arguments; document.MM_tl=new Array; for(i=0;i<(a.length-1);i+=2)	 
   if ((x=MM_findObj(a[i]))!=null){document.MM_tl[j++]=x; if(!x.oTl) x.oTl=x.title; x.title='';}
}
function MM_swapTtlRestore() { //v3.0
  var i,x,a=document.MM_tl; for(i=0;a&&i<a.length&&(x=a[i])&&x.oTl;i++){x.title=x.oTl;}
}
function set_anchor(link){
x='orori_link';
var anchorTag=document.createElement('a');anchorTag.appendChild(document.createTextNode(x));anchorTag.href = link; anchorTag.setAttribute('rel', "lightbox");
Lightbox.click(anchorTag);
}
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
function loadobjs(){
	if (!document.getElementById)
	return
	for (i=0; i<arguments.length; i++){
		var file=arguments[i]
		var fileref=""
		if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
			if (file.indexOf(".js")!=-1){ //If object is a js file
				fileref=document.createElement('script')
				fileref.setAttribute("type","text/javascript");
				fileref.setAttribute("src", file);
			}
			else if (file.indexOf(".css")!=-1){ //If object is a css file
				fileref=document.createElement("link")
				fileref.setAttribute("rel", "stylesheet");
				fileref.setAttribute("type", "text/css");
				fileref.setAttribute("href", file);
			}
		}
		if (fileref!=""){
			document.getElementsByTagName("head").item(0).appendChild(fileref)
			loadedobjects+=file+" " //Remember this object as being already added to page
		}
	}
}

function moveRightEdgeX(follower,banner_top_range){
	//alert('pret');
	//if ((follower_obj=MM_findObj(follower))!=null){
		follower_obj=document.getElementById(follower);
		if(isNS4){
			yMenuFrom=follower_obj.offsetTop;
			yMenuTo=windows.pageYOffset+banner_top_range;
		}else if(isDOM){	
			yMenuFrom=parseInt(follower_obj.offsetTop);
			yMenuTo=(isNS?window.pageYOffset:document.documentElement.scrollTop)+banner_top_range;
		}
		timeoutNextCheck=500;
		var today=new Date();
		//alert(yMenuFrom);
		//document.getElementById('watcher').innerHTML='From:'+yMenuFrom+', To'+yMenuTo;
		if(yMenuFrom!=yMenuTo && (yMenuTo>150 || yMenuTo<yMenuFrom)){
			yMenuTo=yMenuTo-170;
			yOffset=Math.ceil(Math.abs(yMenuTo-yMenuFrom)/20);
			if(yMenuTo < yMenuFrom)yOffset=-yOffset;
			if(isNS4){follower_obj.top+=yOffset;}
			else if(isDOM){
				follower_obj.style.top=(parseInt(follower_obj.offsetTop)+yOffset)+'px';
				timeoutNextCheck=10;
			}
		}
	//}
	setTimeout(function(){moveRightEdgeX(follower,banner_top_range)},10);
}

function modify_attribute(form_name, selection_name, attribute_selection){
	if(typeof(document.forms[form_name].elements[selection_name])!='undefined'){
		selection = document.forms[form_name].elements[selection_name];
		options_length = selection.length;
		for(i=0;i<options_length;i++){
			if(selection.options[i].text.replace(';def=true', '').replace(';def=false', '').replace(/ /g, '').toLowerCase()==attribute_selection.replace(/ /g, '').toLowerCase()){
				selection.selectedIndex = i;
				break;
			}
		}
	}
}
function populate_attributes(form_name){
	var product_id='';
	var form='';
	var attributes='';
	form=document.forms[form_name];
	product_id= form.elements['products_id'].value;
	el=form.elements;
	for(i=0;i<el.length;i++){
		if(el[i].type=='select-one'&&el[i].title!='Please select'){
			attributes+=el[i].name.replace('[','{').replace(']','}').replace('id','')+el[i].value;
		}
	}
	on_products_id=product_id+attributes;
}
function get_subtotal(form_name, item_groups){
	item_group=new Array();
	if(typeof(item_groups)=='string'){
		item_group[0]=item_groups;
	}else{item_group=item_groups;}
	
	form=document.forms[form_name];
	el=form.elements;
	subtotal=0;
	for(j=0;j<item_group.length;j++){
		for(i=0;i<5;i++){
			if(el[item_group[j]+'['+i+']']!=undefined){
				if(el[item_group[j]+'['+i+']'].checked){
					subtotal=subtotal+parseFloat(el['pc_'+item_group[j]+'['+i+']'].value);
				}
			}
		}
	}
	return subtotal;
}

//

/**
*
*  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;
    }

}
function reset_section(split_name, owner, other)
{
	var teddy_ctnDiv = MM_findObj(split_name + '_ctn');
	if((x=MM_findObj(owner))!=null){
		if((y=MM_findObj(other))!=null){
			inspect_objects = y.getElementsByTagName('div');
			for(i=0, n=inspect_objects.length; i<n; i++){
				if(inspect_objects[i].id==split_name)
				{	
					if((label=MM_findObj(split_name + '_label'))!=null){label.style.display='none';}
					if((label=MM_findObj(split_name + '_roof'))!=null){label.style.display='none';}
					if((label=MM_findObj(split_name + '_floor'))!=null){label.style.display='none';}
					y.removeChild(inspect_objects[i]);
					break;
				}
			}
		}
	}
}


function hide_box(box_name)
{
	if((label=MM_findObj(box_name + '_label'))!=null){label.style.display='none';}
	if((label=MM_findObj(box_name + '_roof'))!=null){label.style.display='none';}
	if((label=MM_findObj(box_name + '_floor'))!=null){label.style.display='none';}
}

function serialize( mixed_value ) {
    // http://kevin.vanzonneveld.net
    // +   original by: Arpad Ray (mailto:arpad@php.net)
    // +   improved by: Dino
    // +   bugfixed by: Andrej Pavlovic
    // +   bugfixed by: Garagoth
    // %          note: We feel the main purpose of this function should be to ease the transport of data between php & js
    // %          note: Aiming for PHP-compatibility, we have to translate objects to arrays
    // *     example 1: serialize(['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'
    // *     example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'});
    // *     returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'
 
    var _getType = function( inp ) {
        var type = typeof inp, match;
        var key;
        if (type == 'object' && !inp) {
            return 'null';
        }
        if (type == "object") {
            if (!inp.constructor) {
                return 'object';
            }
            var cons = inp.constructor.toString();
            match = cons.match(/(\w+)\(/);
            if (match) {
                cons = match[1].toLowerCase();
            }
            var types = ["boolean", "number", "string", "array"];
            for (key in types) {
                if (cons == types[key]) {
                    type = types[key];
                    break;
                }
            }
        }
        return type;
    };
    var type = _getType(mixed_value);
    var val, ktype = '';
    
    switch (type) {
        case "function": 
            val = ""; 
            break;
        case "undefined":
            val = "N";
            break;
        case "boolean":
            val = "b:" + (mixed_value ? "1" : "0");
            break;
        case "number":
            val = (Math.round(mixed_value) == mixed_value ? "i" : "d") + ":" + mixed_value;
            break;
        case "string":
            val = "s:" + mixed_value.length + ":\"" + mixed_value + "\"";
            break;
        case "array":
        case "object":
            val = "a";
            /*
            if (type == "object") {
                var objname = mixed_value.constructor.toString().match(/(\w+)\(\)/);
                if (objname == undefined) {
                    return;
                }
                objname[1] = serialize(objname[1]);
                val = "O" + objname[1].substring(1, objname[1].length - 1);
            }
            */
            var count = 0;
            var vals = "";
            var okey;
            var key;
            for (key in mixed_value) {
                ktype = _getType(mixed_value[key]);
                if (ktype == "function") { 
                    continue; 
                }
                
                okey = (key.match(/^[0-9]+$/) ? parseInt(key, 10) : key);
                vals += serialize(okey) +
                        serialize(mixed_value[key]);
                count++;
            }
            val += ":" + count + ":{" + vals + "}";
            break;
    }
    if (type != "object" && type != "array") {
      val += ";";
  }
    return val;
}
function add(fooform,type, name, value) {

	//Create an input type dynamically.
	var element = document.createElement("input");

	//Assign different attributes to the element.
	element.setAttribute("type", type);
	element.setAttribute("value", value);
	element.setAttribute("name", name);

	//Append the element in page (in span).
	fooform.appendChild(element);

}