function loadcustomorderform(link,wrapperid){
    	//AJAX REQUEST
    if (wrapperid) {
        new Ajax.Request(link, {
            method: "get",
            onComplete: function(transport) {
                $(wrapperid).innerHTML = transport.responseText;
            } //-onSuccess
        }//-request arguments
		); // new ajax request	
    }

}

function loadcustomorderformRTD(link,wrapperid){
    	//AJAX REQUEST
    if (wrapperid){
    
    new Ajax.Request(link, {
	method: "post",
	onComplete: function(transport) { 
		$(wrapperid).innerHTML = transport.responseText; 
		}//-onSuccess
		}//-request arguments
		);// new ajax request	
    }

}


function submitorderform(formname, link, wrapperid, catalogid, catid, tid, addtocart) {
  
    var keepgoing = true;
    if(catalogid != '' && catalogid != undefined){
        $("CatalogIDs").value = catalogid;
		$("CatalogIDp").value = catalogid;
		$("tid").value = tid
    }
    
    if ($('catalogid').value !=''){
        if(validateform(formname,'yellow','#eee')){	
            keepgoing = true;
        } else {
            keepgoing = false;
        }
    }
    
    if (keepgoing){
        
        $('addtocartindicator').style.display = 'block';
      //AJAX POST
	    var Digital=new Date()
        var seconds=Digital.getSeconds()
        var hours=Digital.getHours()
        var minutes=Digital.getMinutes()
        // + '?catid=' + catid + '&tid=' + tid + '&refresh=' + seconds + hours + minutes
        new Ajax.Request(link, {
            method: "post",
            parameters: Form.serialize(document.forms[formname]),
            onComplete: function (transport) {
                $(wrapperid).innerHTML = transport.responseText;
               
                //return false;
                //if (($('catalogid').value !='' && $('item_qty').value !=''  && $('Sequence').value !=''  && $('OligoName').value !='' && addtocart == '1'  ) || ($('ppSynthScale').value != 'none' && addtocart == '1') || (addtocart == '1') || $('plexitemid').value != '' ){
                if (((validateform(formname, '#ffff00', '#eeeeee')) && (addtocart == '1') && document.getElementById('SynthScale').value != 'none') || ($('plexitemid').value != '')) {
                    //custom add to cart
                    var Digital = new Date()
                    var seconds = Digital.getSeconds()
                    var hours = Digital.getHours()
                    var minutes = Digital.getMinutes()

                    //console.log(new Date().getMilliseconds());

                    new Ajax.Request('/sc_addtocart.ashx?refresh=' + seconds + hours + minutes, {
                        method: "post",
                        parameters: Form.serialize(document.forms[formname]),
                        onSuccess: function (transport, formname) {
                            var resp = transport.responseText.split("^");
                            $('ctl00_sc_cartcount').innerHTML = resp[0];
                            $('ctl00_sc_carttotal').innerHTML = resp[1];
                            $('addtocartindicator').style.display = 'none';
                            Lightbox.showBoxByID('hiddenDiv', 205, 177);
                            //refreshcart('refreshcart');      
                        } //-onSuccess
                    }//-request arguments
                ); // new ajax request


                }

            } //-onSuccess
        }//-request arguments
		    ); // new ajax request	
    }
}

function submitorderform2(formname, link, wrapperid, catalogid, catid, tid, addtocart) {
    var keepgoing = true;
    if(catalogid != '' && catalogid != undefined){
        $("CatalogIDs").value = catalogid;
		$("CatalogIDp").value = catalogid;
		$("tid").value = tid
    }
    
    if ($('catalogid').value !=''){
        if(validateform(formname,'yellow','#eee')){	
            keepgoing = true;
        } else {
            keepgoing = false;
        }
    }
    
    if (keepgoing){
        
        $('addtocartindicator').style.display = 'block';
      //AJAX POST
	    var Digital=new Date()
        var seconds=Digital.getSeconds()
        var hours=Digital.getHours()
        var minutes=Digital.getMinutes()
        // + '?catid=' + catid + '&tid=' + tid + '&refresh=' + seconds + hours + minutes
        new Ajax.Request(link, {
	    method: "post",
        parameters: Form.serialize(document.forms[formname]),
	    onComplete: function(transport) { 
		    $(wrapperid).innerHTML = transport.responseText; 
                
                //return false;
		    //if (($('catalogid').value !='' && $('item_qty').value !=''  && $('Sequence').value !=''  && $('OligoName').value !='' && addtocart == '1'  ) || ($('ppSynthScale').value != 'none' && addtocart == '1') || (addtocart == '1') || $('plexitemid').value != '' ){
		    if  (((validateform(formname,'#ffff00','#eeeeee')) && (addtocart == '1')) || ($('plexitemid').value != '')){
		        //custom add to cart
                var Digital=new Date()
                var seconds=Digital.getSeconds()
                var hours=Digital.getHours()
                var minutes=Digital.getMinutes()
                new Ajax.Request('/sc_addtocart.ashx?refresh=' + seconds + hours + minutes + '&sc_cart_next=true', {
                method: "post",
                parameters: Form.serialize(document.forms[formname]),
                onSuccess: function(transport,formname) { 	
                        var resp = transport.responseText.split("^");
                        $('ctl00_sc_cartcount').innerHTML = resp[0];
                        $('ctl00_sc_carttotal').innerHTML = resp[1];
            	        $('addtocartindicator').style.display = 'none';
            	        $('addtocartmessage2').innerHTML = 'Assay added to cart. Please click on the second link above to continue. ';
            	        $("CatalogIDs").value = catalogid;
            	        //window.location = 'http://www.biosearchtech.com/secure/accept2.aspx?DesignRunOrderID=' + $('DesignRunOrderID').value + '&snp=1'

                        //Lightbox.showBoxByID('hiddenDiv', 205 ,177);
                        //refreshcart('refreshcart');      
		                }//-onSuccess
                    }//-request arguments
                );// new ajax request
    
		        
		    }
		    
		    }//-onSuccess
		    }//-request arguments
		    );// new ajax request	
    }
}


//LOG IN
function logina(formname,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){				
		//AJAX POST
		new Ajax.Request('/sc_login.ashx', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onSuccess: function(transport,formname) { 	
			//LOG IN EXISTS?
			var theid = 'validatemessage';
			if (transport.responseText=='true'){			
					document.getElementById(theid).innerHTML = '';
					//document.forms.login.submit();
					document.location.reload();
			} else {
				document.getElementById(theid).innerHTML = 'Invalid Log In';
				if (document.getElementById(theid).style.display == "none"){
				Effect.Appear(theid,'blind');
				} else {
				Effect.Shake(theid);
				}
			}
		}//-onSuccess
		}//-request arguments
		);// new ajax request		
	}
}

//LOG OUT
function logout() {
	//AJAX REQUEST
	new Ajax.Request('/sc_logout.ashx', {
	method: "get",
	onComplete: function(transport) { 
		document.location.reload();
		}//-onSuccess
		}//-request arguments
		);// new ajax request		
}

//VALIDATION
function createaccount(formname,validateid,indicatorid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){	 

	    document.forms[formname].__VIEWSTATE.name = 'NOVIEWSTATE';
	    document.forms[formname].__VIEWSTATE.id= 'NOVIEWSTATE';

		new Ajax.Request('sc_createnewaccount.ashx', {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onComplete: function(transport) {
		        var r = transport.responseText; 
		        if (!r.indexOf("KeepGoing")){
		            document.forms[formname].NOVIEWSTATE.name = '__VIEWSTATE';
		            document.forms[formname].NOVIEWSTATE.id = '__VIEWSTATE';
		            document.forms[formname].submit();
		        } else {
		            document.getElementById(indicatorid).style.display = "none";
		            document.getElementById(validateid).innerHTML = r;
                    formfieldbg(r,"Zip","billing_zip",color1,color2);
                    formfieldbg(r,"Email","billing_email",color1,color2);
                    formfieldbg(r,"Username","newuser",color1,color2);
                    formfieldbg(r,"Passwords","newpassword",color1,color2);
                    formfieldbg(r,"Passwords","newpassword2",color1,color2);	           
		            if (document.getElementById(validateid).style.display == "none"){
		                document.getElementById(validateid).style.display = "block";
		            } else {
		                Effect.Shake(validateid);
		            }
		        }
			}
		}
		);
	} else {
	    document.getElementById(validateid).innerHTML = 'Please fill in Required Fields.';
	    if (document.getElementById(validateid).style.display == "none"){
			Effect.Appear(validateid,'blind');
		} else {
			Effect.Shake(validateid);
		}
	}
}

function showmenu(themenu){
	if ($(themenu).style.display == "none"){
		$(themenu).style.display = "block"
	} else {
		$(themenu).style.display = "none"
	}
}

function loaddiv(divid,ajaxpage,tab,handle){
	//TABS
	var x=document.getElementsByTagName("img");
	for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf(handle)>-1){
			var element = document.getElementById(x[i].id);
			if (element.id == tab){
				element.src = element.src.replace('/off/','/on/')
			} else {
				element.onmouseover = tabover;
				element.onclick = tabclick; 
				element.onmouseout = tabout; 
				element.src = element.src.replace('/on/','/off/')
			}
		}
	}
	
	//AJAX REQUEST
	new Ajax.Request(ajaxpage, {
	method: "get",
	onComplete: function(transport) { 
		document.getElementById(divid).innerHTML = transport.responseText;
		}//-onSuccess
		}//-request arguments
		);// new ajax request	
}

//TYPE OF PROBLEM
function problem(level,parentid){
    level += 1;
    var x=document.getElementsByTagName("div");
    var ii = 0
    var handle  = 'problem-name-' + level + '-' + parentid + '-'
	for (var i=0;i<x.length;i++){
	    if (x[i].id.indexOf(handle)>-1){
	        var element = document.getElementById(x[i].id);
			var theid = element.id.replace(handle,'');
			if (document.getElementById(handle + theid).style.display == 'block'){
			   	document.getElementById(handle + theid).style.display = 'none';
			} else {
			    document.getElementById(handle + theid).style.display = 'block';
			}	
	    }
	}
}

function spidermenus(triggerhandle,menuhandle){
	var x=document.getElementsByTagName("div");

	for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf(triggerhandle)>-1){
			//VARIABLES
			var element = document.getElementById(x[i].id);
			var theid = element.id.replace(triggerhandle,'');
            
			//TRIGGERS
			var thetrigger = document.getElementById(triggerhandle + theid);
			thetrigger.onmouseover = function() {  
			    this.style.position = 'relative';
				var menutoswitch;
				menutoswitch = this.id.replace('trigger','');
				
				if($('slidewrapper')){
				    $('slidewrapper').style.zIndex = '-100';
				}
				
			
				
				document.getElementById(menutoswitch).style.display = "block";
				var navimg = this.id.replace('menutrigger','');
				if ($('nav' + navimg)){
				document.getElementById('nav' + navimg).src = document.getElementById('nav' + navimg).src.replace('/off/','/roll/');
			    }
			    };
			thetrigger.onmouseout = function() {
			    this.style.position = 'static';
			    
			    if($('slidewrapper')){
			        $('slidewrapper').style.zIndex = '100';
			    }
			    
				var menutoswitch;
				menutoswitch = this.id.replace('trigger','');
				document.getElementById(menutoswitch).style.display = "none";
                var navimg = this.id.replace('menutrigger','');
                if ($('nav' + navimg)){
				document.getElementById('nav' + navimg).src = document.getElementById('nav' + navimg).src.replace('/roll/','/off/');
			    }
			};
			
		} 
	}
}

//VALIDATION
function validEmail(email) {
	var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	return re.test(email); 
}
		
//VALIDATION
function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}
		
//VALIDATION
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
		
//VALIDATION
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}
		
//VALIDATION
function isFilled(elm) {
	//alert(elm.type);
	//Last Updated by Sol - 6/14/07
	switch(elm.type){
	case "text":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "password":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "textarea":
		if (trim(elm.value) == "" || elm.value == null){
		return false;}
		else {return true;}
		break;
	case "select-one":
		var myindex=elm.selectedIndex;
		if (myindex==0){
		return false;}
		else {return true;}
		break;
	}
}

//VALIDATION
function validateform(formname,color1,color2){
	//last updated on 9/27/07
	//index of is mo betta
	var x = document.forms[formname];
	var allgood = true;
	for (var i=0;i<x.length;i++){
		if (x.elements[i].className.indexOf('required')>-1) {
		 	var thisformname = x.elements[i].name;
			var thisformid = x.elements[i].id;
			if (!isFilled(x.elements[i])) {
				document.getElementById(thisformid).style.background = color1;
				allgood = false;
				} else {
				  document.getElementById(thisformid).style.background = color2; 
				}
			}
		}
		if (allgood) {
			return true;
			} else {
			return false;
			}
	}
	
function arethesame(condition1,condition2){
	if (condition1 == condition2) {
			return true;
			} else {
			return false;
			}
}
	
function spiderform(formname,validateid,successid,indicatorid,ajaxpage) {

	//VALIDATE REQUIRED
	if(validateform(formname,'yellow','yellow')){	
		//alert(formname);
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'appear');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(indicatorid).style.display = "none";
			document.getElementById(successid).style.display = "block";	
			document.getElementById(successid).innerHTML = transport.responseText;				
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

function spiderform2(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname,'#fcf76e','#fcf76e')){	
	
		//EMAIL IS VALID?
		var email = document.getElementById("email").value;
		if(!validEmail(email)){
			document.getElementById("email").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'appear');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(indicatorid).style.display = "none";
			document.getElementById(successid).style.display = "block";	
			document.getElementById(successid).innerHTML = transport.responseText;				
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

function spiderformcontact(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	

	if(validateform(formname,'#f9f7cb','#f9f7cb')){	
	
		//EMAIL IS VALID?
		var email = document.getElementById("emailcontact").value;
		if(!validEmail(email)){
			document.getElementById("emailcontact").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'appear');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(successid).innerHTML = transport.responseText;
			document.getElementById(indicatorid).style.display = "none";			
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

// SPECIAL FOR EDIT ACCOUNT

function spiderformaccount(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname,'#f9f7cb','#f9f7cb')){	
	
		//EMAIL IS VALID?
		var email = document.getElementById("sc_editaccount_email").value;
		if(!validEmail(email)){
			document.getElementById("sc_editaccount_email").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'appear');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(successid).innerHTML = transport.responseText;
			document.getElementById(indicatorid).style.display = "none";			
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}


//UPDATE PASSWORD
function updatepassword(formname,validateid,ajax) {
	var p = document.getElementById("password").value;
	if(p.length <5) {
	    document.getElementById(validateid).innerHTML = 'Your password is too short.';
		document.getElementById("password").style.background = '#f9f7cb';
	} else {
	//VALIDATE REQUIRED
	if(validateform(formname,'#f9f7cb','#f9f7cb')){
		//PASSWORDS	MATCH?
		var condition1 = document.getElementById("password").value;
		var condition2 = document.getElementById("password2").value;
		if (!arethesame(condition1,condition2)){
			document.getElementById("password").style.background = '#f9f7cb'; 
			document.getElementById("password2").style.background = '#f9f7cb';  
			document.getElementById(validateid).innerHTML = 'Your Password Does Not Match';
		} else {	 
		new Ajax.Request(ajax, {
		method: "post",
		parameters: Form.serialize(document.forms[formname]),
		onComplete: function(transport) {
			    document.getElementById("password").style.background = '#ffffff'; 
			    document.getElementById("password2").style.background = '#ffffff';  
				document.getElementById(validateid).innerHTML = transport.responseText;
				//fadeout(validateid);
			}
		}
		);
	}
	} else {
	    document.getElementById(validateid).innerHTML = 'Please fill in Required Fields.';
	    if (document.getElementById(validateid).style.display == "none"){
			Effect.Appear(validateid,'blind');
		} else {
			Effect.Shake(validateid);
		}
	}
}
}

function spidersignup(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname,'#f9f7cb','#f9f7cb')){	
	
		//EMAIL IS VALID?
		var email = document.getElementById("emailsignup").value;
		if(!validEmail(email)){
			document.getElementById("emailsignup").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'appear');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {	
			document.getElementById(indicatorid).style.display = "none";
			document.getElementById(successid).style.display = "block";	
			document.getElementById(successid).innerHTML = transport.responseText;	
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

function spiderfriend(formname,validateid,successid,indicatorid,ajaxpage) {
	//VALIDATE REQUIRED
	if(validateform(formname,'#f9f7cb','#f9f7cb')){	
	
		//EMAIL IS VALID?
		var friendemailfrom = document.getElementById("friendemailfrom").value;
		var friendemailto = document.getElementById("friendemailto").value;
		if(!validEmail(friendemailfrom)){
			document.getElementById("friendemailfrom").style.background = "white"; 
			document.getElementById(validateid).innerHTML = 'Invalid Email';
			if (document.getElementById(validateid).style.display == "none"){
					Effect.Appear(validateid,'blind');
					} else {
					Effect.Shake(validateid);
					}
			} else {
			document.getElementById(validateid).style.display = "none";
			document.getElementById(indicatorid).style.display = "block";
			//alert('got here')
			//AJAX POST
			new Ajax.Request(ajaxpage, {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onComplete: function(transport) {		
			document.getElementById(successid).innerHTML = transport.responseText;
			document.getElementById(indicatorid).style.display = "none";
				//alert(transport.responseText);			
				
				}//-onSuccess
			}//-request arguments
			);// new ajax request	
			
			//document.form.formname.submit();	
			}
	}
}

//EMAIL PASSWORD
function emailpassworda(formname,validateid,color1,color2) {
	//VALIDATE REQUIRED
	if(validateform(formname,color1,color2)){
		//EMAIL IS VALID?
		//alert(document.getElementById("passwordemail").value);
		var email = document.getElementById("passwordemail").value;
		var theid = validateid;

		if(validEmail(email)){
		
			//AJAX POST
			new Ajax.Request('sc_emailpassword.ashx', {
			method: "post",
			parameters: Form.serialize(document.forms[formname]),
			onSuccess: function(transport,formname) { 
				var validatemessage
				var theid = validateid;
				//USER IS AVAILABLE?
				if (transport.responseText=='true'){	
					document.getElementById(validateid).innerHTML = 'Your password has been emailed.';
					Effect.Appear(validateid,'blind');
					var t = setTimeout("Effect.toggle('" + validateid + "');",2000);
				} else {
					document.getElementById(theid).innerHTML = transport.responseText;
					if (document.getElementById(theid).style.display == "none"){
					Effect.Appear(theid,'blind');
					} else {
					Effect.Shake(theid);
					}
				}
				}
				}
				);// new ajax request
			} else {
				document.getElementById(theid).innerHTML = 'Invalid Email';
				document.getElementById("passwordemail").style.background = "yellow"; 
				if (document.getElementById(theid).style.display == "none"){
					Effect.Appear(theid,'blind');
					} else {
					Effect.Shake(theid);
			}
		}
	}
}

function spiderwindow(url,name,width,height){
    mywindow = window.open(url, name, 'location=0,status=0,scrollbars=0,width=' + width + ',height=' + height);
    mywindow.focus();
 }
 
 //DELETE FROM CART
function remsavedcart(cid){
	Effect.Fade('cartrow' + cid);
	
	//AJAX POST
	new Ajax.Request('/sc_deletecart.ashx?id=' + cid, {
	method: "get",
	onComplete: function(transport) { 
		}//-onSuccess
		}//-request arguments
		);// new ajax request
} 

//IMAGE ROLLOVER
function rolloverInit(){
	var x=document.getElementsByTagName("img");
    for (var i=0;i<x.length;i++){
	    if (x[i].className.indexOf('rollover')>-1){
	        x[i].onmouseover = function() {
	            this.src = this.src.replace('/off/','/roll/')
	        }
	        x[i].onmouseout = function() {
	            this.src = this.src.replace('/roll/','/off/')
	        }
	    }
	}
}

function getcatalogid() {
	var dye = $('dye').value;
	var deliveredamount = $('deliveredamount').value;
	var catalogid = dye + '-' + deliveredamount;
	if (dye != '' && deliveredamount != '') {
		$('catalogidshow').innerHTML = catalogid;
		$('catalogid').value = catalogid;

		switch (catalogid) {
	        case 'SMF-1000-5':
	            $('item_itemid').value = '5192';
	            break;
	        case 'SMF-1000-1':
	            $('item_itemid').value = '5193';
	            break;

	        case 'SMF-1001-1':
	            $('item_itemid').value = '5206';
	            break;
	        case 'SMF-1001-5':
	            $('item_itemid').value = '5207';
	            break;

	        case 'SMF-1063-5':
	            $('item_itemid').value = '5229';
	            break;
	        case 'SMF-1063-1':
	            $('item_itemid').value = '5230';
	            break;

	        case 'SMF-1065-5':
	            $('item_itemid').value = '5231';
	            break;
	        case 'SMF-1065-1':
	            $('item_itemid').value = '5232';
	            break;

	        case 'SMF-1081-5':
	            $('item_itemid').value = '5234';
	            break;
	        case 'SMF-1081-1':
	            $('item_itemid').value = '5235';
	            break;

	        case 'SMF-1082-5':
	            $('item_itemid').value = '5236';
	            break;
	        case 'SMF-1082-1':
	            $('item_itemid').value = '5237';
	            break;

	        case 'SMF-1083-5':
	            $('item_itemid').value = '5238';
	            break;
	        case 'SMF-1083-1':
	            $('item_itemid').value = '5239';
	            break;

	        case 'SMF-1084-5':
	            $('item_itemid').value = '5241';
	            break;
	        case 'SMF-1084-1':
	            $('item_itemid').value = '5242';
	            break;

	        case 'SMF-1025-5':
	            $('item_itemid').value = '5265';
	            break;
	        case 'SMF-1025-1':
	            $('item_itemid').value = '5266';
	            break;

	        case 'SMF-3003-5':
	            $('item_itemid').value = '5329';
	            break;
	        case 'SMF-3003-1':
	            $('item_itemid').value = '5334';
	            break;

	        case 'SMF-3033-5':
	            $('item_itemid').value = '5335';
	            break;
	        case 'SMF-3033-1':
	            $('item_itemid').value = '5336';
	            break;

	        case 'SMF-1067-5':
	            $('item_itemid').value = '5349';
	            break;
	        case 'SMF-1067-1':
	            $('item_itemid').value = '5350';
	            break;	 	            	            	
	        default:
	            $('item_itemid').value = '';
		}
	}
}

function deletestellaris(rowid, sequenceid) {
    $(sequenceid).value = '';
    Effect.Fade(rowid);
}

//IMAGE ROLLOVER
//Last Update August 1, 2008
function setupRollover(thisImage) {
	thisImage.outImage = new Image();
	thisImage.outImage.src = thisImage.src;
	//alert(thisImage.id);
	thisImage.outImage.id = thisImage.id;
	thisImage.onmouseout = rollOut;
	thisImage.overImage = new Image();
	thisImage.overImage.id = thisImage.id
	thisImage.overImage.src = thisImage.src.replace('/off/','/roll/')
	thisImage.onmouseover = rollOver;
}

//IMAGE ROLLOVER
function rollOver() {
	this.src = this.overImage.src;
}

//IMAGE ROLLOVER
function rollOut() {
	this.src = this.outImage.src;
}

function scroll1(){
    setInterval('scrollright()',50);
}

function scrollright(){
    var width = 100;
    this.increment = 100;
    var me = this;
    var left = $('upcomingajaxwrapper').style.left;
    if (parseInt(left) >= -430){
        //var top = $('listcontainer').style.top;
        $('upcomingajaxwrapper').style.left = parseInt(left) - me.increment + 'px';
        //$('scrolldown').style.display = 'block';
    }
    else{
        //$('scrollup').style.display = 'none';
    }
}

//SLIDE
function SlidesShow(){
    //PROPERTIES
    this.slideTotal = 0;
    this.slideContainer = ''; //ID NAME
    this.slideWrapper = '';//ID NAME
    this.nextButton = ''; //ID OF HREF(SO THAT ELEMENT CAN BE TEXT OR IMAGE)
    this.prevButton = '';
    this.slideIncrement = 15; //SLIDE INCREMENTS
    this.slideHeight = 350; // WIDTH OF EACH DIV OR IMAGE
    this.next = nextSlide;
    this.previous = prevSlide;
    this.nextUrl = '';
    this.prevUrl = '';
  
    //VARIABLES
    var loopI = 0; //KEEPS TRACK OF EACH slideIncrement FROM 0 TO slideHeight, 50, 100, 150, 200
    var goNext = null;
    var goBack = null;
    var me = this;
    
    function setProperties(){
          me.prevUrl = document.getElementById(me.prevButton).style.href;
          me.nextUrl = document.getElementById(me.nextButton).style.href;
    }
    
    //METHODS
    function nextSlide(){  
	    document.getElementById(me.prevButton).style.display = "block";
	    goNext = setInterval(nextSlideDetail,1);
    }
    
    function prevSlide(){
	    goBack = setInterval(prevSlideDetail,1);
    }
    
    function nextSlideDetail(slideEnd,nextUrl){
        document.getElementById(me.nextButton).removeAttribute("href");  
	    var slideStart = parseFloat(document.getElementById(me.slideContainer).style.top);
	    slideEnd = slideStart - me.slideHeight;
	    var endFrame = 0 - ((me.slideTotal-1) * me.slideHeight);
	     
	    var addIncrement;
	    if ((loopI + me.slideIncrement) > me.slideHeight){

	         addIncrement = me.slideHeight -loopI;
	    } else {
	        addIncrement = me.slideIncrement;
	    }

	    loopI += me.slideIncrement;
	    if(slideEnd <= endFrame){
		     document.getElementById(me.nextButton).style.display = "none";
	    }
	    
	    document.getElementById(me.slideContainer).style.top = slideStart - addIncrement + 'px';
	    if(loopI>=me.slideHeight){
	        document.getElementById(me.nextButton).setAttribute('href',me.nextUrl);
		    clearInterval(goNext);
		    loopI = 0;
	    }
    }
    
    function prevSlideDetail(){
        document.getElementById(me.prevButton).removeAttribute("href");
	    var slideStart = parseFloat(document.getElementById(me.slideContainer).style.top);
	    slideEnd = slideStart + me.slideHeight;    
	        
	    var addIncrement;
	    if ((loopI + me.slideIncrement) > me.slideHeight){
	         addIncrement = me.slideHeight -loopI;
	    } else {
	        addIncrement = me.slideIncrement;
	    }
	    loopI += me.slideIncrement;
 
	    document.getElementById(me.slideContainer).style.top = slideStart + addIncrement + 'px';
	    if(loopI>=me.slideHeight){
	        document.getElementById(me.prevButton).setAttribute('href', me.prevUrl);
		    clearInterval(goBack);
		    loopI = 0;
		    if(slideStart == -addIncrement){
		       document.getElementById(me.prevButton).style.display = "none";
		        document.getElementById(me.nextButton).style.display = "block";
		    } else {
                document.getElementById(me.nextButton).style.display = "block";
		    }
	    }
    }
}


//POSITIONING FOR TOOLTIP
function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

function findPosY(obj)
  {
    var curtop = 0; 
    if(obj.offsetParent)
        while(1)
        {
         
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }

function tooltip(divid){	
	var xzero = findPosX(document.getElementById('gridwrapper'));
	var yzero = findPosY(document.getElementById('gridwrapper'));
	var e = document.getElementById(divid);
	var qv = document.getElementById('tooltip');
	var x = findPosX(e) - xzero;
	var y = findPosY(e) - yzero;
	//alert('test');
	qv.style.left = x-6 + 'px';
    qv.style.top = y+15 + 'px';
    $('tooltip').style.display = "block";
    $('tooltip').onmouseover = function() {
        $('tooltip').style.display = "block";
        
    }
	$(divid).onmouseout = function() {
        $('tooltip').style.display = "none";
    }
    $('tooltip').onmouseout = function() {
        $('tooltip').style.display = "none";
    }
}

function InitializeToolTips(){

    var x=document.getElementsByTagName("div");
	for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf('icon')>-1){
            var pageid = x[i].id.replace('icon','');
            var iconid = x[i].id;
            var tooltipid = 'tooltip' + pageid;
            //var eventicon = 'eventtypeimg' + pageid;
            
		    $(iconid).onmouseover = function(){
		        this.style.position = "relative";
		        var toolid = 'tooltip' +  this.id.replace('icon','');
		        $(toolid).style.display = "block";
		        var eventid = 'eventtypeimg' +  this.id.replace('icon','');
		        var roll = $(eventid).src.replace("/large/","/large/on/");
		        if (roll.indexOf('/on/on') == -1){
		            $(eventid).src = roll;
		        }
		    }
		    
		    $(tooltipid).onmouseover = function(){
		
		        $(this.id).style.display = "none";
		    
		    } 

		    $(iconid).onmouseout = function(){
		        var tooltipid = 'tooltip' +  this.id.replace('icon','');
		        $(tooltipid).style.display = "none";
		        this.style.position = "static";
		        
		        var eventid = 'eventtypeimg' +  this.id.replace('icon','');
		        var roll = $(eventid).src.replace("/large/on/","/large/");
		        
		        $(eventid).src = roll;
		    }
		    
//		    $('tooltip' + pageid).onmouseout = function(){
//		       $(this.id).style.display = "none";
//		    }
		}
    }
}

function hoverdates(){
    var x=document.getElementsByTagName("td");
	for (var i=0;i<x.length;i++){
		if (x[i].className.indexOf('vDay')>-1){
		    x[i].style.cursor = 'pointer';
		    x[i].onmouseover = function(){
		        this.style.backgroundColor = '#fff';
		    }
		    x[i].onmouseout = function(){
		        this.style.backgroundColor = '#f0ede3';
		    }
//		    x[i].onclick = function(){
//		        document.location.href = '/list.aspx?day=';
//		    }
		}
    }
}

function clearfield(id){
    $(id).value = '';
}

function searchitem(id,title){
	var x=document.getElementsByTagName("div");
	for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf(id)>-1){
		    x[i].onmouseover = function(){
		        this.style.backgroundColor = '#f6f4ef';
		        var handle = this.id.replace(id,'');
		        var searchtitle = title + handle;
		        $(searchtitle).style.color = '#e9376B';
		    }
		    x[i].onmouseout = function(){
		        this.style.backgroundColor = '#fff';
		        var handle = this.id.replace(id,'');
		        var searchtitle = title + handle;
		        $(searchtitle).style.color = '#342e2e';
		    }
		}
	}
}

function joinhover(name,img){
    var x=document.getElementsByTagName("a");
	for (var i=0;i<x.length;i++){
	    if (x[i].id.indexOf(name)>-1){
		    x[i].onmouseover = function(){
		        var handle = this.id.replace(name,'');
	            var arrow = img + handle;
		        $(arrow).src = '/images/arrowon.gif';
		    }
            x[i].onmouseout = function(){
                var handle = this.id.replace(name,'');
	            var arrow = img + handle;
	            $(arrow).src = '/images/arrowoff.gif';
	        }
	    }
	}
}

function nav(id) {
    var x=document.getElementsByTagName("div");
    for (var i=0;i<x.length;i++){
		if (x[i].id.indexOf(id)>-1){
		    var element = document.getElementById(x[i].id);
		    var theid = element.id.replace(id,'');
		    //var theid = element.id.replace('_drop','');
		    //var theid = theid + "_drop";
		    //alert(theid);
            var dropdiv = document.getElementById(id + theid);
            dropdiv.onmouseover = function() {
                var navtoswitch = this.id;
                document.getElementById(navtoswitch).style.color = "#a6d1e1";
            }
            dropdiv.onmouseout = function() {
                //alert('hi1');
                var navtoswitch = this.id;
                document.getElementById(navtoswitch).style.color = "#e9f3f1";
            }
        }
    }
}

function navoff(){
    $('nav5').src = '/images/buttons/off/ordernow.gif';
}

var DDSPEED = 10;
var DDTIMER = 15;

// main function to handle the mouse events //
function ddMenu(id,d){
    //alert('asd');
    //$('nav5').src = '/images/buttons/off/ordernow.gif';
    var h = document.getElementById(id + '-ddheader');
    var c = document.getElementById(id + '-ddcontent');
    clearInterval(c.timer);

    if(d == 1){
        clearTimeout(h.timer);
    if(c.maxh && c.maxh <= c.offsetHeight){return}
        else if(!c.maxh){
            c.style.display = 'block';
            c.style.height = 'auto';
            c.maxh = c.offsetHeight;
            c.style.height = '0px';
        }
        c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
        }else{
        h.timer = setTimeout(function(){ddCollapse(c)},50);
        
    }
}

// collapse the menu //
function ddCollapse(c){
    c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
//    setTimeout(c.style.display = 'none',5000);
}

// cancel the collapse if a user rolls over the dropdown //
function cancelHide(id){
    $('nav5').src = '/images/buttons/roll/ordernow.gif';
    var h = document.getElementById(id + '-ddheader');
    var c = document.getElementById(id + '-ddcontent');
    clearTimeout(h.timer);
    clearInterval(c.timer);
    
    if(c.offsetHeight < c.maxh){
        c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
    }
}

// incrementally expand/contract the dropdown and change the opacity //
function ddSlide(c,d){
    var currh = c.offsetHeight;
    var dist;
    if(d == 1){
        dist = (Math.round((c.maxh - currh) / DDSPEED));
    }else{
        dist = (Math.round(currh / DDSPEED));
    }
    if(dist <= 1 && d == 1){
        dist = 1;
    }
    c.style.height = currh + (dist * d) + 'px';
    c.style.opacity = currh / c.maxh;
    c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
    if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
        clearInterval(c.timer);
    }
}

function shoh(div) {
    if (document.getElementById(div).style.display == "none" ){
 	    document.getElementById(div).style.display = "block";
    } else {
 	    document.getElementById(div).style.display = "none"
    }
}

function changeimg(id,sequence){
    if($(sequence).style.display == 'none'){
        $(id).src = "/images/buttons/close.gif";
    } else {
        $(id).src = "/images/buttons/view.gif";
    }
}

window.onload = masterloader;

function masterloader(){
    joinhover('joinlink','arrow');
    hoverdates();
	rolloverInit();
	spidermenus('menutrigger','menu');
	InitializeToolTips();
	searchitem('searchresult','searchtitle');
	nav('drop');
    //nav1();
}
