//order confirmation and order receipt page - split the email address on the RHN if too long
function splitEmailAdd(usemail) {
	var stringlist = new Array();
	while (usemail.length > 30) {
	   stringlist.push( usemail.slice(0,30));
	   usemail=usemail.substr(30);
	}
	if (usemail.length) {
	  stringlist.push(usemail);
	}
	document.write(stringlist.join( '<br>' ));
}

// Variables for dynamic nav
turnonToggle = 1; //change this to 0 if you don't want to use toggling
// Bullet images
// change path to the desired location
shown = new Image();
shown.src = "/venda-support/images/bulleton.gif";
hidden = new Image();
hidden.src = "/venda-support/images/bulletoff.gif";
//following function to be removed when RT#98865 in stable
function dynamicContent(where,what) {
	// find out what tag the function is called from so the correct value is passed for url
	identifyTag = where.tagName;
	if (identifyTag == "A"){
		ajaxFunction(where+'&layout=noheaders&temp=subcategories',what);
		if (turnonToggle == 1){toggle(where);}
	} else if (identifyTag == "INPUT" || identifyTag == "SELECT") {
		ajaxFunction(where.value,what);
	}
};

//Description: Returns the value of a specified URL parameter 
//Parameters:
//1. currURL = this is the URL which you wish to get the URL parameter value from
//2. urlParam = this is the name of the URL parameter you want to get the value for
//Returns: value for parameter specified urlParam.
function grabURL(currURL,urlParam) {
	//find out a value where is passed from current url
	var url = unescape(currURL);
	var spliter = '&';
	var sField = spliter+urlParam+'=';
	
	if (url.search(sField) == -1) {               
		sField = '?'+urlParam+'=';         
	}
	
	var urlArray = url.split(sField);
	if (urlArray[1]) {
		//get url param value
		var paramArray = urlArray[1].split(spliter);
		return(paramArray[0]);
	}
}

//This function is  for validating  userextendedfiields on registration and edit profile page. You may edit this to suit your user extended fields.
// frmObj is the  form  object in which the user extended fields reside.
function validateUserExtendedFields(frmObj) {
	if(frmObj) {				
		return true;		
	} 
	return false;
}

function validateQty(iform){
var iNum = /\D/;
var qty = iform.qty;

    if(iNum.test(qty.value)==true){
        alert("Please enter numbers only");
        return false;
    }
    else if(qty.value < "1"){
        alert("Please enter numbers more than 0."); 
    }
    else{
         iform.submit();
    }		
}	

// This function is used for defaulting the quantity to 1 or to make the quantity positive incase the user enters it wrong by mistake
function qtyValidate(thisBox,item){
  var regExp = /\D/g;
  var nonNum= thisBox.value.match(regExp);

    if(item > 0) {
        if ((nonNum != null) && (nonNum.length > 0) || (thisBox.value == "")) {
             thisBox.value = item;       
        }
    }else{
        if ((nonNum != null) && (nonNum.length > 0) || (thisBox.value == 0)) {
            thisBox.value = 1;        
        }
    }

}  

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 getCookie(c_name){
	if (document.cookie.length>0){
		c_start = document.cookie.indexOf(c_name + "=");
  	 
		if (c_start!=-1){
			c_start = c_start + c_name.length+1;
			c_end = document.cookie.indexOf(";",c_start);
				if (c_end==-1) c_end = document.cookie.length;
					return unescape(document.cookie.substring(c_start,c_end));
				}
		}
		return null
}
  	 
function replaceData(s){
	var sdata=s;
	sdata=sdata.replace(/\+/g, '-');
	sdata=sdata.replace(/\//g, '_');
	return sdata;
}
  	 
function delete_cookie( cookie_name ){
	var cookie_date = new Date();  // current date & time
	cookie_date.setTime(cookie_date.getTime());
	document.cookie = cookie_name+"=; expires=" + cookie_date.toGMTString()+"; path=/";
	return true;
}

