	 /**
	 * Short description for file
	 * This file lists the prelimanary configuration 
	 * parameters that are required to initiate application.
	 *
	 * PHP versions 4.2+
	 * MySQL versions 4.1.11+
	 * Javascript versions 1.2+
	 *
	 * @category   Application File (Common - Javascript functions)
	 * @package    Auction.com
	 * @author     Precision Snipers <snipers@pretechno.com>
	 * @copyright  1997-2005 Precision Technologies <info@pretechno.com>
	 * @license    As described below
	 * @version    1.2.0
	 * @link       http://pretechno.com
	 * @see        -NA-
	 * @since      File available since Release 1.2.0 dt. Saturday, 05 August, 2006
	 * @deprecated -NA-
	 */

	/*********************************************************
	* Licence:
	* This file is sole property of Precision Technologies.
	* Any type of copy or reproduction without the consent
	* of Precision Technologies is prohibited.
	* If in any case used leave this part intact without 
	* any modification.
	* All Rights Reserved
	* Copyright 2006 Precision Technologies
	*******************************************************/

// BO: Article pagination.
	/**
	 * Function to retrieve the text on the spedcified page of the Article.
	 */
	function getArticlePage(from, aid, sid, page) {
		createObject();
		//var element = document.getElementById('article'+id_num);
		//element.innerHTML = '<div style="height: 20px;"><em>Loading ...</em></div>';
		query = 'act=getArticlePage&aid='+ aid +'&sid='+ sid +'&page='+ page;
		objXmlHttp.open('get', from +'?'+ query);
		objXmlHttp.onreadystatechange = putArticlePage;
		objXmlHttp.send(null);
		return true;
	}
	/**
	 * Function to fill the text of the spedcified page of the Article.
	 */
	function putArticlePage() {
	   if(objXmlHttp.readyState == 4){
			if (objXmlHttp.status == 200){
				var element = document.getElementById('pagearticle');
				element.innerHTML = objXmlHttp.responseText;
				objXmlHttp = null;
			}
		}
	}
// EO: Article pagination.





	/**
	* Function to check maximum characters
	* that can be entered in an text area
	*/
	function ismaxlength(obj)
	{		
		var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
		
		if (obj.getAttribute && obj.value.length>mlength)
		obj.value=obj.value.substring(0,mlength);		
	}
	
	/**
	 * This function is used to create the query string format of 
	 * all the elements that are present within the scope of the 
	 * form that has been passed as an argument.
	 *
	 * @param	form element	The form for which the query string is to be created.
	 *
	 * @return	querystring		the querystring format of all the elements is retunred back.
	 */
	function createQueryString(form) {
		var query_string = "";
		for (var i = 0; i < form.elements.length; i++) {
	
			switch (form.elements[i].type) {
				case ("text"): {
					query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;					
					break;
				}
				case ("textarea"): {
					if ( form.elements[i].value != "" ) {
						query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
					}
					break;
				}
				case ("hidden"): {
					if ( form.elements[i].value != "" ) {
						query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
					}
					break;
				}
				case ("checkbox"): {
					if ( form.elements[i].checked ) {
						query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
					}
					break;
				}
				case ("select-one"): {
					query_string += "&"+ form.elements[i].name 
										+"="+ form.elements[i].options[form.elements[i].selectedIndex].value;
					break;
				}
				case ("select-multiple"): {
					s_options = "";
					for ( j=0; j < form.elements[i].length; j++ ) {
						if ( form.elements[i].options[j].selected ) {
							s_options += ","+ form.elements[i].options[j].value;
						}
					}
					if (s_options != "") {
						s_options = s_options.substr(1);
						query_string += "&"+ form.elements[i].name +"="+ s_options;
					}
					break;
				}
				case ("radio"): {
					if ( form.elements[i].checked ) {
						query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
					}
					break;
				}
	/*			case ("submit"): {
					if ( form.elements[i].value != "" ) {
						query_string += "&"+ form.elements[i].name +"="+ form.elements[i].value;
					}
					break;
				}*/
			}
		}
		return (query_string);
	}
	
	function clearText( ele, step, eleval )
	{
		if( step==1)
		{
			if( document.getElementById(ele).value == eleval )
			{
				document.getElementById(ele).value='';
			}
		}
		else if( step ==2 )
		{
			if( document.getElementById(ele).value == "")
			{
				document.getElementById(ele).value = eleval;
			}
		}
	}
	
	function openSmallWindow(url,vwidth,vheight)
	    {
				if(vwidth=="0") {vwidth=250; }
				if(vheight=="0") {vheight=250; }
				var win_param;
				
				LeftPosition = (screen.width) ? (screen.width-vwidth)/2 : 0;
				TopPosition = (screen.height) ? (screen.height-vheight)/2 : 0;
			
				win_param="top="+TopPosition+",left="+LeftPosition+",width="+vwidth+",height="+vheight+"channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0,screenX=0,left=75,top=75,screenY=0";
				msgWindow=open(url,"SmallWindow",win_param);
				msgWindow.focus();
				msgWindow.opener= self;
				return false;
				
	   }	
	
	
	function reallyDel( msg )
	{
		if(!confirm( msg ) )
		{
			return false;
		}
	}
	
	function toggle_VISIBILITY( ele )
	{	
		if(document.getElementById( ele ).className=='showdiv')
		{
			document.getElementById( ele ).className='hidediv'
		}
		else{
			document.getElementById( ele ).className='showdiv'
		}		
	}

	function validate_PHONE(obj, fldName)
	{
		//Commented for Netscape Crash Error - Have to be replaced		
		//var exp = /^[0-9a-zA-Z()_-]+(\S|\s)[0-9a-zA-Z()_-]+$/		
		var exp = /^[0-9a-zA-Z()_-]+(\S|\s)[0-9a-zA-Z()_-]+(\S|\s)[0-9a-zA-Z()_-]+$/		
		return checkExp(exp, obj, "ERROR :: Please enter a valid " + fldName )
	}


	function validate_URL(obj, fldName)
	{
		var exp = "^(((ht|f)tp(s?))\://)?(www.)?[a-zA-Z0-9\-\.\&]+\.(ac|as|be|biz|ca|cc|com|co.in|co.il|co.uk|co.nz|co.za|com.ru|com.ph|de|dk|edu|fm|gs|gov|il|info|jp|kz|lt|ms|mil|museum|nz|net|net.nz|name|org|org.il|org.nz|org.uk|ph|pro|ro|sh|st|tc|to|tv|uk|us|vg|vu|ws|za<b>[a-z][a-z]</b>)(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$";
		var strRegExp = new RegExp(); 
		strRegExp.compile(exp); 
		if (!strRegExp.test(obj.value)) { 
                alert("ERROR :: Please enter a valid "+ fldName +"."); 
                obj.focus();
                return false; 
        } 
        return true;
	}


	function validate_TEXT(obj, fldName)
	{
		//Commented for Netscape Crash Error - Have to be replaced
		var exp = /^(\S|\s)+$/
		return checkExp(exp, obj, "ERROR :: The " + fldName + " must be filled out")
	}

	function validate_VALIDNAME(obj, fldName)
	{
		
		//Commented for Netscape Crash Error - Have to be replaced
		var exp = /^[a-zA-Z]+(\S|\s)*[0-9a-zA-Z]+$/
		return checkExp(exp, obj, "ERROR :: Please enter a valid " + fldName )
	}
	
	function validate_EMPTYNAME(obj, fldName)
	{   
		if(obj.value == "")
		{
			alert("ERROR :: Please enter "+ fldName)
			obj.focus()
			return false
		}
		else 
			return true
		
	}

	function validate_USERNAME(obj, fldName)
	{
		var exp = /^[a-zA-Z]+\w{4,}[0-9a-zA-Z]+$/
		return checkExp(exp, obj, "ERROR :: The "+ fldName +"  must be at least 7 characters long (it accepts a-zA-Z0-9 and _ only)")
	}

	function validate_CODE(obj, fldName)
	{
		var exp = /^[a-zA-Z]+[\w|\-]{4,}[0-9a-zA-Z]+$/
		return checkExp(exp, obj, "ERROR :: Please enter valid code")
	}

	function validate_ZIP(obj, fldName)
	{
		var exp = /^\d{4,10}$/
		return checkExp(exp, obj, "ERROR :: Please enter a valid ZIP code (4 digits atleast)")
	}

	/*function validate_PHONE(obj, fldName)
	{
		var exp = /^((\(\d{3}\) ?)|(\d{3}(-| )?))\d{3}(-| )?\d{4}$/
		return checkExp(exp, obj, "Please enter a valid "+ fldName +" number (10 digits)")
	}
	function validate_MOBILEPHONE(obj, fldName)
	{
		var exp = /^((\(\d{3}\) ?)|(\d{3}(-| )?))\d{3}(-| )?\d{4}$/
		return checkExp(exp, obj, "Please enter a valid "+ fldName +" number (10 digits)")
	}*/
	function validate_EMAIL(obj, fldName)
	{
		var exp = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/
		return checkExp(exp, obj, "ERROR :: Please enter a valid email address")
	}
	
	function validate_UPC(obj, fldName)
	{
		var exp = /(^\d{6}$)|(^\d{12}$)/
		return checkExp(exp, obj, "ERROR :: Please enter a valid UPC code (6 or 12 digits)")
	}

	function validate_SSN(obj, fldName)
	{
		var exp = /^\d{3}-\d{2}-\d{4}$/
		return checkExp(exp, obj, "ERROR :: Please enter a valid tax ID or SSN in the format nnn-nn-nnnn")
	}

	function validate_WEIGHT(obj, fldName)
	{
		if (validate_DOUBLE(obj, fldName))
			if (obj.value <= 0)
			{
				alert("ERROR :: Please enter a number greater than zero for the weight")
				obj.focus();
				return false
			}
			else
				return true
		else
			return false
	}
	
	function validate_CURRENCY(obj, fldName)
	{
		obj.value = obj.value.replace("$", "")
		//obj.value = obj.value.replace(",", "")
		obj.value = strReplace(obj.value,",","")
		
		if (validate_DOUBLE(obj, fldName))
			if (obj.value < 0)
			{
				alert("ERROR :: Please enter a number greater or equal to zero for the " + fldName)
				obj.focus();	
				return false
			}
			else
			{
				obj.value = parseInt((parseFloat(obj.value) + 0.005) * 100) / 100
				return true
			}
		else
			return false		
	}	
	
	function validate_INTEGER(obj, fldName)
	{
		var val = parseInt(parseInt(obj.value) + 0.5)
		if (isNaN(val) || obj.value == "")
		{
			alert("ERROR :: Please enter a numeric " + fldName + " value")
			obj.focus();	
			return false
		}
		else
		{
			obj.value = val
			return true
		}
	}

	function validate_DOUBLE(obj, fldName)
	{
		var val = parseFloat(strReplace(obj.value,",",""))
		
		if (isNaN(val) || obj.value == "")
		{
			alert("ERROR :: Please enter a numeric value for the " + fldName)
			obj.focus();	
			return false
		}

		obj.value = val
		return true
	}
	
	function validate_DATE(obj, fldName)
	{
  		var testDate=new Date(Date.parse(obj.value));
		
		if(!testDate.getYear())
		{
		    alert("ERROR :: Please enter a valid " + fldName);
			obj.focus();
		    return false;
		}
		
		obj.value = testDate.getMonth() + 1 + "/" + testDate.getDate() + "/" + testDate.getYear()
		return true
	}
	
	function validate_DROPDOWN(obj, fldName)
	{	
		if (obj.selectedIndex == 0)
		{
			alert("ERROR :: Please select an option for the " + fldName)
			obj.focus();
			return false
		}
		
		return true
	}
	
	function validate_CUSTOM(obj)
	{
		return true
	}

	function validate_FILE(obj, fldName)
	{
		if (obj.value == "")
		{
			alert("ERROR :: Please browse for a file")
			obj.focus();
			return false
		}
		
		return true
	}

	function validate_TEXTAREA(obj, maxlen)
	{
		if (validate_TEXT(obj))
			if (obj.value.length > parseInt(maxlen))
			{
				alert("ERROR :: Please shorten your message.")
				obj.focus();
				return false
			}
			else
				return true
		else
			return false
	}

	function validate_CHECKBOX(obj, fldName)
	{
		if(obj.checked == 1)
		{
			return true
		}
		else 
		{ 
			alert("ERROR :: Please checked "+ fldName )
			return false
		}
	}
	
	function validate_CUSTOM(obj)
	{
		return true
	}

	function validate_PASSWORD(obj)
	{
		var exp = /^([0-9a-zA-Z]){6,10}$/
		return checkExp(exp, obj, "The password must be at least 6 characters long (letters and numbers only)")
	}
	
	function validate_CONFIRMPASSWORD(obj1,obj2)
	{
		if (obj1.value!=obj2.value)
		{
		alert("ERROR :: Password do not match each other.");
		obj2.focus();
		return false;
		}
		return true;

	}
	function validate_CONFIRMEMAIL(obj1,obj2)
	{
		if (obj1.value!=obj2.value)
		{
		alert("ERROR :: Email address do not match each other.");
		obj2.focus();
		return false;
		}
		return true;

	}

	function validate_HIDDEN(obj, fldName)
	{
		return true
	}		
	
	function trim(value)
	{
   		var exp = /^(\s*)(\S*)(\s*$)/;
   		if (exp.test(value)) 
   			value = value.replace(exp, '$2');
   			
   		return value;
   	}

	function checkExp(exp, obj, message)
	{
		obj.value = trim(obj.value)
				
		if (!exp.exec(obj.value))
		{
			alert(message);
			obj.focus();
			return false;
		}		
		
		return true;
	}

	function strReplace(strVal,strFrom,strTo)
	{
		var i;
		var strRes='';
		for(i=0;i<strVal.length;i++)
			{
			ch=strVal.substring(i,i+1);
			strRes+=ch==strFrom?strTo:ch
			}
		return strRes;
	}
	
	
	//============= CREDIT CARD VALIDATION =====================//
	function validateCC(CCno,CCname) 
	// CCno is the card number
	// CCname is the name of the issuer of the card 
	{
	  Cno=CCno; 
	  Cno = Cno.split(' ').join('');
	  CCname = CCname.toLowerCase().split(' ').join();
	  
	  switch (CCname)
	  { 
	     case "visa" :
	        if (((Cno.length == 16) || (Cno.length == 13)) && (Cno.substring(0,1) == 4))
	        { 
	           return DOmod10(Cno); 
	        } 
	        return false; 
	     case "mastercard" : 
	          chr1 = Cno.substring(0,1); 
	          chr2 = Cno.substring(1,2); 
	          if ((Cno.length == 16) && (chr1 == 5) && ((chr2 >= 1) && (chr2 <= 5))) 
	         {
	             return DOmod10(Cno);
	         } 
	         return false; 
	      case "americanexpress" : 
	         chr1 = Cno.substring(0,1); 
	         chr2 = Cno.substring(1,2); 
	         if ((Cno.length == 15) && (chr1 == 3) && ((chr2 == 4) || (chr2 == 7))) 
	         {
	            return DOmod10(Cno); 
	         }
	         return false; 
	     case "dinersclub" : 
	        chr1 = Cno.substring(0,1); 
	        chr2 = Cno.substring(1,2); 
	        if ((Cno.length == 14) && (chr1 == 3) && ((chr2 == 0) || (chr2 == 6) || (chr2 == 8))) 
	        {
	            return DOmod10(Cno); 
	        }
	        return false; 
	     case "discover" : 
	        chr1to4 = Cno.substring(0,4); 
	        if ((Cno.length == 16) && (chr1to4 == "6011")) 
	       {
	           return DOmod10(Cno);
	       }
	       return false; 
	  }
	  return false; 
	} 

	function DOmod10(numstr) 
	{ 
		if (numstr.length > 19) 
		{
		  return (false); 
		}
		tot = 0;
		len = numstr.length; 
		mult = 1;
		Totval = 0;
		for (i = 0; i < len; i++)
		{ 
			  chrval = numstr.substring(len-i-1,len-i); 
			  Totval = parseInt(chrval ,10)*mult; 
			  if (Totval >= 10) 
			  {
				 tot += (Totval % 10) + 1; 
			  }
			  else 
			  {
				 tot += Totval; 
			  } 
			  if (mult == 1)
			  { 
				 mult++; 
			  }
			  else 
			  {
				 mult--; 
			  }
		} 
		if ((tot % 10) == 0) 
		{
		  return true; 
		}
		else
		{ 
		  return false; 
		} 
	}