var global_location="includes";
function checkBlank(inputid,message)
{
			if(document.getElementById(inputid))  
			{ 
				className=document.getElementById(inputid).className;
				className=className.replace("borderred", "");
				if(document.getElementById(inputid).value=='')
				{
					document.getElementById(inputid).className=className+" borderred";
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML =message;
					}
					return false;
				}
				else
				{
					document.getElementById(inputid).className=className;
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML ='';
					}
					return true;
				}
			
			}
	return true;

}
function setlength(field)
{
	if(field){
		var len=field.value.length;
		var field_name=field.name;
		if(document.getElementById(field_name+"_count")){
			document.getElementById(field_name+"_count").innerHTML=len;
		}
		
	}
}

function checkMailValid(inputid,message)
{
	if(document.getElementById(inputid))  
	{ 
		className=document.getElementById(inputid).className;
		className=className.replace("borderred", "");
		if(document.getElementById(inputid).value!='')
		{   
			return checkMail(inputid,message);
		}
		else
		{
			document.getElementById(inputid).className=className+" borderred";
			if(document.getElementById(inputid+"_err")){ 
				document.getElementById(inputid+"_err").innerHTML =message;
			}
			return false;
		}
	}
}


function validate(type,inputid,message)
{
inputid=inputid.name;
	var err=0;
	setlength(document.getElementById(inputid));
	if(type=='mail')  
	{
		if(checkMailValid(inputid,message)==false) {
			err=err+1;

		}
	}
	
	else if(type=='url'){
		
	    if(chkurl(inputid,message)==false){
	       err=err+1;
    	}
	}
	
	else if(type=='requair'){
		if(checkBlank(inputid,message)==false) {
			err=err+1;

		}
	}
	else if(type=='cpassword'){
		if(checkcpassword(inputid,message)==false) {
			err=err+1;

		}
	}

	 else if(type=='numeric'){
		if(checkNumeric(inputid)==false){
		err=err+1;
		}		
	}

	else if(type=='userid'){
		if(checkuserid(inputid,message)==false) {
			err=err+1;

		}
	}	

	else if(type=='code'){
		if(checkcode(inputid,message)==false) {
			err=err+1;

		}
	}
	
	if(err==0)
		return true;
	else 
		return false;
}

function checkMail(inputid,message)
{
	if(document.getElementById(inputid))  
	{ 

	classname=document.getElementById(inputid).className;
	classname=classname.replace("borderred", "");
		var mailvalue=trim(document.getElementById(inputid).value);
			var mailsplit=mailvalue.split(",");
			for(var i=0;i<mailsplit.length;i++){
				var filter =/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
				if (filter.test(mailsplit[i])) {
					   document.getElementById(inputid).className=classname;
						if(document.getElementById(inputid+"_err"))
						{ 
							document.getElementById(inputid+"_err").innerHTML ='';
						}
						return true;
				}
				else {
					  
						document.getElementById(inputid).className=classname+" borderred";
						if(document.getElementById(inputid+"_err"))
						{ 
							document.getElementById(inputid+"_err").innerHTML = messages['invalid_email'];
						}
						return false;
				}
			}
	}
}

function chkurl(inputid,message)
{
	if(document.getElementById(inputid))  
	{ 
		var URL=document.getElementById(inputid).value;
		var regexp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	
	className=document.getElementById(inputid).className;
	className=className.replace("borderred", "");
	
		if(URL!='')
			{  
				if (regexp.test(URL)){
					
				    	document.getElementById(inputid).className=className;
						if(document.getElementById(inputid+"_err"))
						{ 
							document.getElementById(inputid+"_err").innerHTML ='';
						}
						return true;
						
				}
				else {
					
					    document.getElementById(inputid).className=className+" borderred";
						if(document.getElementById(inputid+"_err"))
						{ 
							document.getElementById(inputid+"_err").innerHTML =message;
						}
						return false;
						
				}
			}
			else {
						document.getElementById(inputid).className=className+" borderred";
						if(document.getElementById(inputid+"_err"))
						{ 
							document.getElementById(inputid+"_err").innerHTML =messages['specify_url'];
						}
						return false;
			}
			return true;
	}
}



function checkuserid(inputid,message)
{
	var Submit=document.getElementById("Submit").value;

		if(Submit=="Update")
			return false;

			if(document.getElementById(inputid))  
			{ 
				var className=document.getElementById(inputid).className;
				var user_name=document.getElementById(inputid).value;
				className=className.replace("borderred", "");
				if(document.getElementById(inputid).value=='')
				{
					document.getElementById(inputid).className=className+" borderred";
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML =message;
					}
					return false;
				}
				else
				{
							advAJAX.get({
						url: global_location+'/frndbconfig.php?QT=4&Username='+user_name,
						onInitialization : function() {
						//						loginMessage).innerHTML="&nbsp;<img src='assets/load.gif'>";	  
						}, 
						onSuccess : function(obj) { 
						document.getElementById(inputid+"_err").innerHTML =obj.responseText;
									if(obj.responseText == 0)
									{
										document.getElementById(inputid).className=className;
										if(document.getElementById(inputid+"_err"))
										{ 
											document.getElementById(inputid+"_err").innerHTML ="<span style='color:green'>"+messages['uesrid_available'];
										}
										return true;
									}	
									else
									{
										document.getElementById(inputid).className=className+" borderred";
										if(document.getElementById(inputid+"_err"))
										{ 
											document.getElementById(inputid+"_err").innerHTML =messages['uesrid_notavailable'];
										}
										return false;
									}	
								},
						onError : function(obj) {
								  alert('Error: ' + obj.status);
							  },
						onFinalization : function(){
								 }
						});
				}
			
			}
}

function checkcode(inputid,message)
{
	
			if(document.getElementById(inputid))  
			{ 
				var className=document.getElementById(inputid).className;
				var code=document.getElementById(inputid).value;
				className=className.replace("borderred", "");
				if(document.getElementById(inputid).value=='')
				{
					document.getElementById(inputid).className=className+" borderred";
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML =message;
					}
					return false;
				}
				else
				{
							advAJAX.get({
						url: global_location+'/frndbconfig.php?QT=26&code='+code,
						onInitialization : function() {
						//						loginMessage).innerHTML="&nbsp;<img src='assets/load.gif'>";	  
						}, 
						onSuccess : function(obj) { 
									if(obj.responseText == 0)
									{
										document.getElementById(inputid).className=className;
										return true;
									}	
									else
									{
										document.getElementById(inputid).className=className+" borderred";
										if(document.getElementById(inputid+"_err"))
										{ 
											document.getElementById(inputid+"_err").innerHTML =messages['security_img'];
										}
										return false;
									}	
								},
						onError : function(obj) {
								  alert('Error: ' + obj.status);
							  },
						onFinalization : function(){
								 }
						});
				}
			
			}
}




function checkuserid2(inputid,message,err)
{
 var className=document.getElementById(inputid).className;
 var user_name=document.getElementById(inputid).value;
				advAJAX.get({
			url: global_location+'/frndbconfig.php?QT=4&Username='+user_name,
			onInitialization : function() {
			//						loginMessage).innerHTML="&nbsp;<img src='assets/load.gif'>";	  
			}, 
			onSuccess : function(obj) { 
			document.getElementById(inputid+"_err").innerHTML =obj.responseText;
						if(obj.responseText == 0)
						{
							document.getElementById(inputid).className=className;
							if(document.getElementById(inputid+"_err"))
							{ 
								document.getElementById(inputid+"_err").innerHTML ="<span style='color:green'>"+messages['uesrid_available'];
							}
						}	
						else
						{
							document.getElementById(inputid).className=className+" borderred";
							if(document.getElementById(inputid+"_err"))
							{ 
								document.getElementById(inputid+"_err").innerHTML =messages['uesrid_notavailable'];
								err=err+1;
							}
						}	
						checkcode2('code',messages['security_img'],err);
					},
			onError : function(obj) {
					  alert('Error: ' + obj.status);
				  },
			onFinalization : function(){
					 }
			});
}

function checkcode2(inputid,message,err)
{
 var className=document.getElementById(inputid).className;
 var code=document.getElementById(inputid).value;

advAJAX.get({
			url: global_location+'/frndbconfig.php?QT=26&code='+code,
			onInitialization : function() {
			//						loginMessage).innerHTML="&nbsp;<img src='assets/load.gif'>";	  
			}, 
			onSuccess : function(obj) { 
						if(obj.responseText == 0)
						{
							document.getElementById(inputid).className=className;
						}	
						else
						{
							document.getElementById(inputid).className=className+" borderred";
							if(document.getElementById(inputid+"_err"))
							{ 
								document.getElementById(inputid+"_err").innerHTML =messages['security_img'];
							}
							err=err+1;
						}	
						
						if(err==0)
								{
									document.registration.action=global_location+"/frndbconfig.php?QT=2";
									document.registration.submit();
								}
							else
								return false;
					},
			onError : function(obj) {
					  alert('Error: ' + obj.status);
				  },
			onFinalization : function(){
					 }
			});
}



function checkcpassword(inputid,message)
{
			if(document.getElementById(inputid))  
			{ 
				var className=document.getElementById(inputid).className;
				var password=document.getElementById("pwd").value;
				var cpassword=document.getElementById(inputid).value;
				className=className.replace("borderred", "");
				if(cpassword=='')
				{
					document.getElementById(inputid).className=className+" borderred";
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML = messages['enter_cpassword'];
					}
					return false;
				}
				else if(cpassword != password)
					{document.getElementById(inputid).className=className+" borderred";
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML = message;
					}
					return false;					
				}
				else
				{
					document.getElementById(inputid).className=className;
					if(document.getElementById(inputid+"_err"))
					{ 
						document.getElementById(inputid+"_err").innerHTML ='';
					}
					return true;
				}
			}

	return true;

}

function checkNumeric(id)
	{
	   if(document.getElementById(id).value==''){
	    document.getElementById(id).className='inputtext';
		document.getElementById(id+'_err').innerHTML='';
		return true;
	   }
	   if(document.getElementById(id).value!=''){
		var ph=document.getElementById(id).value;
		if(isNaN(ph)){ 
		document.getElementById(id).className='inputtext borderred';
		document.getElementById(id+'_err').innerHTML=messages['only_numeric'];
		return false;
		}
		else
		{ 
		 document.getElementById(id).className='inputtext';
		document.getElementById(id+'_err').innerHTML='';
		return true;
		}
	 }
   }
   
function resetForm(formid)
{
//	resetCounter();
	var element;
	var i=0;
	var className
	var x=document.getElementById(formid);
	for (i=0;i<x.length;i++)
	{
		element=(x.elements[i].id);
		if(document.getElementById(element))  
		{ 
			className=document.getElementById(element).className;
			className=className.replace("borderred", "");
			document.getElementById(element).className=className;
		}
		if(document.getElementById(element+"_err"))  
		{ 
			document.getElementById(element+"_err").innerHTML='';
		}
		if(document.getElementById(element+"_count"))  
		{ 
			document.getElementById(element+"_count").innerHTML='0';
		}
		
	}
}

function trim(str)
{
	s = str.replace(/^(\s)*/, '');
	s = s.replace(/(\s)*$/, '');
	return s;
}


function Validate_registration(f_name,email,user_id,pwd,cpwd,add1,country,code)
{
var err=0;

		if(checkBlank(f_name,messages['require_fname'])==false) {
			err=err+1;
		}

		if(checkMailValid(email,messages['chk_email'])==false) {
			err=err+1;

		}

		if(checkBlank(user_id,messages['enter_username'])==false) {
			err=err+1;

		}

	if(checkBlank(pwd,messages['enter_password'])==false) {
			err=err+1;

		}

		if(checkcpassword(cpwd,messages['enter_cusername'])==false) {
			err=err+1;

		}

		if(checkBlank(add1,messages['require_address'])==false) {
			err=err+1;

		}

		if(checkBlank(country,messages['require_country'])==false) {
			err=err+1;

		}
		
		if(checkBlank(code,messages['security_img'])==false) {
			err=err+1;

		}
	 var Submit=document.getElementById("Submit").value;
	 	if(Submit=="Update")
			checkcode2('code',messages['security_img'],err);
		else
			checkuserid2(user_id,messages['enter_username'],err);
		
/*	if (!checkuserid(user_id,messages['enter_username'])){
			err=err+1;
		}
		
	if (!checkcode(code,messages['security_img'])){
			err=err+1;
		}	
*/
}
function Validate_editprofile(f_name,email,add1,country)
{
var err=0;

		if(checkBlank(f_name,messages['require_fname'])==false) {
			err=err+1;
		}

		if(checkMailValid(email,messages['chk_email'])==false) {
			err=err+1;

		}
		
		if(checkBlank(add1,messages['require_address'])==false) {
			err=err+1;

		}

		if(checkBlank(country,messages['require_country'])==false) {
			err=err+1;

		}
	if(err==0){
		if(checkuserid(user_id,messages['enter_username'])==false) {
			return false;
		}
		else
		{
			document.registration.action=global_location+"/frndbconfig.php?QT=9";
			document.registration.submit();
		}

	}
	else
		return false;

}




function setMaxLength2(element){
	if(element){
		var maxLength = element.getAttribute('maxlength');
			var currentLength = element.value.length;
				var field_name=element.name;
				if(document.getElementById(field_name+"_count")){
					document.getElementById(field_name+"_count").innerHTML=currentLength;
				}
			if (currentLength > maxLength) {
				element.value = element.value.substring(0, maxLength);
			}		
	}
}

function Validate_feedback(f_name,email,message)
{
var err=0;

		if(checkBlank(f_name,messages['require_fname'])==false) {
			err=err+1;
		}

		if(checkMailValid(email,messages['chk_email'])==false) {
			err=err+1;

		}
		
		if(checkBlank(message,messages['message'])==false) {
			err=err+1;
 	     }

	if(err==0)
		return true;
	else
		return false;

}

function Validate_forgetpass(user_id,email)
{
var err=0;

		if(checkBlank(user_id,messages['login'])==false) {
			err=err+1;
		}

		if(checkMailValid(email,messages['chk_email'])==false) {
			err=err+1;

		}

	if(err==0)
		return true;
	else
		return false;

}

function Validate_login(user_id,pwd)
{
var err=0;

		if(checkBlank(user_id,messages['login'])==false) {
			err=err+1;
		}

		if(checkBlank(pwd,messages['password'])==false) {
			err=err+1;

		}
		
	if(err==0)
		return true;
	else
		return false;
}

function Validate_cpassword(oldpwd,pwd,cpwd)
{
var err=0;

		if(checkBlank(oldpwd,messages['enter_opassword'])==false) {
			err=err+1;
		}

		if(checkBlank(pwd,messages['enter_password'])==false) {
			err=err+1;

		}
		if(checkcpassword(cpwd,messages['enter_cpassword'])==false) {
			err=err+1;

		}
	if(err==0)
		return true;
	else
		return false;
}

function Validate_ship(bname,baddress,bcity,bcountry,bphone,bemail,sname,saddress,scity,scountry,sphone,semail,state,zip,sstate,szip)
{
var err=0;

		if(checkBlank(bname,messages['enter_username'])==false) {
			err=err+1;
		}
		if(checkBlank(baddress,messages['require_address'])==false) {
			err=err+1;
		}
		if(checkBlank(bcity,messages['requair_city'])==false) {
			err=err+1;
		}
		if(checkBlank(bcountry,messages['requair_country'])==false) {
			err=err+1;
		}
		if(checkBlank(bphone,messages['requair_phone'])==false) {
			err=err+1;
		}
		if(checkMailValid(bemail,messages['specific_email'])==false) {
			err=err+1;
		}
		if(checkBlank(sname,messages['enter_username'])==false) {
			err=err+1;
		}
		if(checkBlank(saddress,messages['require_address'])==false) {
			err=err+1;
		}
		if(checkBlank(scity,messages['requair_city'])==false) {
			err=err+1;
		}
		if(checkBlank(scountry,messages['requair_country'])==false) {
			err=err+1;
		}
		if(checkBlank(sphone,messages['requair_phone'])==false) {
			err=err+1;
		}
		if(checkMailValid(semail,messages['specific_email'])==false) {
			err=err+1;
		}
		if(checkBlank(state,messages['requair_state'])==false) {
			err=err+1;
		}
		if(checkBlank(zip,messages['requair_zip'])==false) {
			err=err+1;
		}
		if(checkBlank(sstate,messages['requair_state'])==false) {
			err=err+1;
		}
		if(checkBlank(szip,messages['requair_zip'])==false) {
			err=err+1;
		}

	if(err==0)
		return true;
	else
		return false;
}

function showshiptable(id)
{
	if (document.getElementById(id).style.display=="none")
	{
		document.getElementById(id).style.display="block";
	}
	else
	{
		document.getElementById(id).style.display="none";
	}	
}

function closeall(id)
	{
		if(id==1)
			{
				document.getElementById('sub_category2').style.display="none";
				document.getElementById('sub_category3').style.display="none";
			}
		else if(id==2)
			{
				document.getElementById('sub_category1').style.display="none";
				document.getElementById('sub_category3').style.display="none";
			}
		else if(id==3)
			{
				document.getElementById('sub_category1').style.display="none";
				document.getElementById('sub_category2').style.display="none";
			}	
	}

var offsetfromcursorX=22 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=1 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

//document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
//document.write('<img id="dhtmlpointer" src="images/arrow2.png">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}


function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

/* Scrollbar Js starts here*/
// Made by geeeet@ghtml.com
// Keep these two lines and you're free to use this code

// Known bugs :
// If ie4.5 mac, please press apple-t to remove sidebar, otherwise everything is pushed 20px to the right...

// Corrected bugs :
// 25.01.2001 - When the height of the span "content" was less than the height of the span "contentClip" a javascript error occured, function changed : move()
// 21.02.2001 - Scrolling text wasn't selectable in ie, function changed : move()
// 05.03.2001 - Ie x and y coordinates was wrong when page was scrolled, function changed : getMouse()

// 19.04.2001 - Finally able to remove browser-scrollbar if content is longer than the browser is high:
// Just put this in the style-tag right before the end head-tag:
// body {margin-left:0; margin-right:0; margin-top:0; margin-bottom:0; width:100%;height:100%;overflow:hidden}

// Touch me here :-)
var upH = 18; // Height of up-arrow
var upW = 12; // Width of up-arrow
var downH = 18; // Height of down-arrow
var downW = 12; // Width of down-arrow
var dragH = 26; // Height of scrollbar
var dragW = 17; // Width of scrollbar
var scrollH = 161; // Height of scrollbar
var speed = 4; // Scroll speed

// And now... go to the bottom of the page...

// Browser detection
var dom = document.getElementById ? true:false;
var nn4 = document.layers ? true:false;
var ie4 = document.all ? true:false;

var mouseY; // Mouse Y position onclick
var mouseX; // Mouse X position onclick

var clickUp = false; // If click on up-arrow
var clickDown = false; // If click on down-arrow
var clickDrag = false; // If click on scrollbar
var clickAbove = false; // If click above scrollbar
var clickBelow = false; // If click below scrollbar

var timer = setTimeout("",500); // Repeat variable
var upL; // Up-arrow X
var upT; // Up-arrow Y
var downL; // Down-arrow X
var downT; // Down-arrow Y
var dragL; // Scrollbar X
var dragT; // Scrollbar Y
var rulerL; // Ruler X
var rulerT; // Ruler Y
var contentT; // Content layer Y;
var contentH; // Content height
var contentClipH; // Content clip height
var scrollLength; // Number of pixels scrollbar should move
var startY; // Keeps track of offset between mouse and span

// Mousedown
function down(e){
	if((document.layers && e.which!=1) || (document.all && event.button!=1)) return true; // Enables the right mousebutton
	getMouse(e);
	startY = (mouseY - dragT);
	
	// If click on up-arrow
	if(mouseX >= upL && (mouseX <= (upL + upW)) && mouseY >= upT && (mouseY <= (upT + upH))){
		clickUp = true;
		return scrollUp();
	}	
	// Else if click on down-arrow
	else if(mouseX >= downL && (mouseX <= (downL + downW)) && mouseY >= downT && (mouseY <= (downT + downH))){
		clickDown = true;
		return scrollDown();
	}
	// Else if click on scrollbar
	else if(mouseX >= dragL && (mouseX <= (dragL + dragW)) && mouseY >= dragT && (mouseY <= (dragT + dragH))){
		clickDrag = true;
		return false;
	}
	else if(mouseX >= dragL && (mouseX <= (dragL + dragW)) && mouseY >= rulerT && (mouseY <= (rulerT + scrollH))){
		// If click above drag
		if(mouseY < dragT){
			clickAbove = true;
			clickUp = true;
			return scrollUp();
		}
		// Else click below drag
		else{
			clickBelow = true;
			clickDown = true;
			return scrollDown();
		}
	}
	// If no scrolling is to take place
	else{
		return true;
	}
}

// Drag function
function move(e){
	if(clickDrag && contentH > contentClipH){
		getMouse(e);
		dragT = (mouseY - startY);
		
		if(dragT < (rulerT))
			dragT = rulerT;		
		if(dragT > (rulerT + scrollH - dragH))
			dragT = (rulerT + scrollH - dragH);
		
		contentT = ((dragT - rulerT)*(1/scrollLength));
		contentT = eval('-' + contentT);

		moveTo();
		
		// So ie-pc doesn't select gifs
		if(ie4)
			return false;
	}
}

function up(){
	clearTimeout(timer);
	// Resetting variables
	clickUp = false;
	clickDown = false;
	clickDrag = false;
	clickAbove = false;
	clickBelow = false;
	return true;
}

// Reads content layer top
function getT(){
	if(ie4)
		contentT = document.all.content.style.pixelTop;
	else if(nn4)
		contentT = document.contentClip.document.content.top;
	else if(dom)
		contentT = parseInt(document.getElementById("content").style.top);
}

// Reads mouse X and Y coordinates
function getMouse(e){
	if(ie4){
		mouseY = event.clientY + document.body.scrollTop;
		mouseX = event.clientX + document.body.scrollLeft;
	}
	else if(nn4 || dom){
		mouseY = e.pageY;
		mouseX = e.pageX;
	}
}

// Moves the layer
function moveTo(){
	if(ie4){
		document.all.content.style.top = contentT;
		document.all.ruler.style.top = dragT;
		document.all.drag.style.top = dragT;
	}
	else if(nn4){
		document.contentClip.document.content.top = contentT;
		document.ruler.top = dragT;
		document.drag.top = dragT;
	}
	else if(dom){
		document.getElementById("content").style.top = contentT + "px";
		document.getElementById("drag").style.top = dragT + "px";
		document.getElementById("ruler").style.top = dragT + "px";
	}
}

// Scrolls up
function scrollUp(){
	getT();
	
	if(clickAbove){
		if(dragT <= (mouseY-(dragH/2)))
			return up();
	}
	
	if(clickUp){
		if(contentT < 0){		
			dragT = dragT - (speed*scrollLength);
			
			if(dragT < (rulerT))
				dragT = rulerT;
				
			contentT = contentT + speed;
			if(contentT > 0)
				contentT = 0;
			
			moveTo();
			timer = setTimeout("scrollUp()",25);
		}
	}
	return false;
}

// Scrolls down
function scrollDown(){
	getT();
	
	if(clickBelow){
		if(dragT >= (mouseY-(dragH/2)))
			return up();
	}

	if(clickDown){
		if(contentT > -(contentH - contentClipH)){			
			dragT = dragT + (speed*scrollLength);
			if(dragT > (rulerT + scrollH - dragH))
				dragT = (rulerT + scrollH - dragH);
			
			contentT = contentT - speed;
			if(contentT < -(contentH - contentClipH))
				contentT = -(contentH - contentClipH);
			
			moveTo();
			timer = setTimeout("scrollDown()",25);
		}
	}
	return false;
}

function reloadPage(){
	location.reload();
}

/*By adnan*/
function getY(id)
{
var iReturnValue = 0;
elementid=document.getElementById(id)
while( elementid != null ){
iReturnValue += elementid.offsetTop;
elementid = elementid.offsetParent;
}
return iReturnValue;
}

function getX(id)
{
var iReturnValue = 0;
elementid=document.getElementById(id)
while( elementid != null ){
iReturnValue += elementid.offsetLeft;
elementid = elementid.offsetParent;
}
return iReturnValue;
}
/* By Adnan ends here*/
// Preload
function eventLoader(){
	if(ie4){
		// Up-arrow X and Y variables
		upL = document.all.up.style.pixelLeft;
		upT = document.all.up.style.pixelTop;		
		// Down-arrow X and Y variables
		downL = document.all.down.style.pixelLeft;
		downT = document.all.down.style.pixelTop;
		// Scrollbar X and Y variables
		dragL = document.all.drag.style.pixelLeft;
		dragT = document.all.drag.style.pixelTop;		
		// Ruler Y variable
		rulerT = document.all.ruler.style.pixelTop;		
		// Height of content layer and clip layer
		contentH = parseInt(document.all.content.scrollHeight);
		contentClipH = parseInt(document.all.contentClip.style.height);
	}
	else if(nn4){
		// Up-arrow X and Y variables
		upL = document.up.left;
		upT = document.up.top;		
		// Down-arrow X and Y variables
		downL = document.down.left;
		downT = document.down.top;		
		// Scrollbar X and Y variables
		dragL = document.drag.left;
		dragT = document.drag.top;		
		// Ruler Y variable
		rulerT = document.ruler.top;
		// Height of content layer and clip layer
		contentH = document.contentClip.document.content.clip.bottom;
		contentClipH = document.contentClip.clip.bottom;
	}
	else if(dom){
		// Up-arrow X and Y variables
		upL = parseInt(getX("up"));
		upT = parseInt(getY("up"));
		// Down-arrow X and Y variables
		downL = parseInt(getX("down"));
		downT = parseInt(getY("down"));
		// Scrollbar X and Y variables
		dragL = parseInt(getX("drag"));
		dragT = parseInt(getY("drag"));
		// Ruler Y variable
		rulerT = parseInt(getY("ruler"));
		// Height of content layer and clip layer
		contentH = parseInt(document.getElementById("content").offsetHeight);
		contentClipH = parseInt(document.getElementById("contentClip").offsetHeight);
		document.getElementById("content").style.top = 0 + "px";
		
	}
	// Number of pixels scrollbar should move
	scrollLength = ((scrollH-dragH)/(contentH-contentClipH));
	// Initializes event capturing
	if(nn4){
		document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
		window.onresize = reloadPage;
	}
	document.onmousedown = down;
	document.onmousemove = move;
	document.onmouseup = up;
}// JavaScript Document
/* Scrollbar css ends here*/

function changelanguage(sellang)
	{
		advAJAX.get({
			url: global_location+"/frndbconfig.php?QT=16&lang="+sellang,
			onInitialization : function() {
			}, 
			onSuccess : function(obj) {	
			},
			onError : function(obj) {
				/* In case of error we show an alert */
				alert("Error: " + obj.status);
			},
			onFinalization : function(){ 
				/* After all operations we show hidden layer */
			  //  someDiv.style.visibility = "visible";
			}
		});
		pagerefresh();
	}
	
	
function pagerefresh()
		{
			document.refform.action='';
			document.refform.submit();
		}

function update_status(row_id,invoice_id)
{
var status=document.getElementById("o_status_"+row_id).value;
advAJAX.get({
    url: "../includes/dbconfig.php?QT=30&row_id="+row_id+"&status="+status,
    onInitialization : function() {
	 document.getElementById("update_msg").innerHTML="<img src='images/load.gif' height='20px;' width='20px;'>";	  
    }, 
    onSuccess : function(obj) {
		document.getElementById("update_msg").innerHTML=invoice_id+" updated succcessfuly";
    },
    onError : function(obj) {
	
        /* In case of error we show an alert */
        alert("Error: " + obj.status);
    },
    onFinalization : function(){ 
	
        /* After all operations we show hidden layer */
      //  someDiv.style.visibility = "visible";
    }
});
}	

function search_data(msg,action)
{
	
var search_data=document.getElementById("search").value;
	if(search_data=='SEARCH BY KEYWORD/PRODUCT#' || search_data=='')
	{
		document.getElementById("search").className="inputtext borderred";
	}
	else
	{
		document.data_search.action=action;
		document.data_search.submit();
	}
}

function setsession(QT,value)
{
	advAJAX.get({
url:global_location+'/frndbconfig.php?QT='+QT+'&value='+value,
onInitialization : function() {
//						document.getElementById('loginmsg').innerHTML="&nbsp;<img src='assets/load.gif'>";
},
onSuccess : function(obj) {
window.location.href='';
},
onError : function(obj) {
alert('Error: ' + obj.status);
},
onFinalization : function(){
}
});
}


function inilitilaze_poopup(obj)
{
	if(obj=="divlogin")
	{
			if(document.getElementById('divlogin').style.display=='block'){
			document.getElementById('errnote').innerHTML="";
			document.Login.Username.focus();
			}
	}
}
var popupObj;
function popupBox(obj)
{
	popupObj = obj;
	if(!$$('noAction'))
	{
		var newObj = document.createElement("div");
		newObj.id = 'noAction';
		document.body.insertBefore(newObj,$$('page'));
	}
	if($$(obj))
	{
		if($$(obj).style.display =='none')
		{
			$$(obj).style.display = 'block';
			$$('noAction').style.display = 'block';
			$$('noAction').style.height = (document.documentElement.clientHeight+document.documentElement.scrollTop)+'px';
			//$$('noAction').style.height = (document.height)+'px';
			$$(obj).style.zIndex = 1000;
		}
		else
		{
			$$(obj).style.display = 'none';
			$$('noAction').style.height = 'auto';
			$$('noAction').style.display = 'none';
		}
	}

	makeCenter(obj);
	inilitilaze_poopup(obj);
}


function makeCenter(obj)
{
	if($$('noAction'))
	{
	$$('noAction').style.height = (document.documentElement.clientHeight+document.documentElement.scrollTop)+'px';
	var winW =  document.documentElement.clientWidth;
	var winH =  document.documentElement.clientHeight;
	var scrollY = document.documentElement.scrollTop;
	var dimen = this.getDimensions(obj);
	$$(obj).style.left = (winW-dimen.width)/2+'px';
	$$(obj).style.top = (((winH-dimen.height)/2)+scrollY)+'px';
	}
}
function getDimensions(element) {
var element = $$(element);
	if (element.style.display != 'none'){
return {width: element.offsetWidth, height: element.offsetHeight};

}
	var els = element.style;
	var originalVisibility = els.visibility;
	var originalPosition = els.position;
	els.visibility = 'hidden';
	els.position = 'absolute';
	els.display = '';
	var originalWidth = element.clientWidth;
	var originalHeight = element.clientHeight;
	els.display = 'none';
	els.position = originalPosition;
	els.visibility = originalVisibility;
	return {width: originalWidth, height: originalHeight};
}


function $$(par)
{
	return  document.getElementById?document.getElementById(par):(document.all?document.all[par]:false);
}


function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function validate_cart()
{
	document.cart_pro.action="includes/frndbconfig.php?QT=13";
	document.cart_pro.submit();
}

function callme(rowid)
	{
		var chk=confirm("Are you sure you want to remove this product from cart?");
		if(chk==false)
			return false;
		else
			{
				document.cart_pro.action='includes/frndbconfig.php?QT=12&row_id='+rowid;
				document.cart_pro.submit();
			}	
	}

function del_pack(rowid)
	{
		var chk=confirm("Are you sure you want to remove this package from cart?");
		if(chk==false)
			return false;
		else
			{
				document.cart_pro.action='includes/frndbconfig.php?QT=24&row_id='+rowid;
				document.cart_pro.submit();
			}	
	}
	
function get_color(pro_id,size_id)
	{
		advAJAX.get({
			url: global_location+"/frndbconfig.php?QT=25&size_id="+size_id+"&pro_id="+pro_id,
			onInitialization : function() {
		 	//document.getElementById("update_msg").innerHTML="<img src='images/load.gif' height='20px;' width='20px;'>";	  
			}, 
			onSuccess : function(obj) {	
				document.getElementById("cmb_"+pro_id).innerHTML=obj.responseText;	  
			},
			onError : function(obj) {
				/* In case of error we show an alert */
				alert("Error: " + obj.status);
			},
			onFinalization : function(){ 
				/* After all operations we show hidden layer */
			  //  someDiv.style.visibility = "visible";
			}
		});
	}
	
function showotherbox(){
		if(document.getElementById('bstate').value==0){
				document.getElementById('other').style.display= "block";
				document.getElementById('other_err_box').style.display= "block";
		}else{
				document.getElementById('other').style.display= "none";
				document.getElementById('other_err_box').style.display= "none";
		}
}	
function showotherbox1(){
		if(document.getElementById('sstate').value==0){
				document.getElementById('s_other').style.display= "block";
				document.getElementById('s_other_err_box').style.display= "block";
		}else{
				document.getElementById('s_other').style.display= "none";
				document.getElementById('s_other_err_box').style.display= "none";
		}
}	

	


var message="Function Disabled!";

///////////////////////////////////
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}

function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}

if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}

document.oncontextmenu=new Function("return false")
