// JavaScript Document

function checkhttp(strpassed)
{
		var strr=strpassed.value
		strextn=strr.substr(0,4)
		strextn=strextn.toUpperCase();
		
		if(strextn=='HTTP')
		{
			alert("Do not add http:// before your website URL (eg.www.billboard.com)");
			
		}	
		
		return true;
}

//if (!chkcardno(dom.password,"Enter Password with Minimum 3 Characters")) {  return false; }
function chkcardno(str,msg)
{	
	var strr=str.value;
	var strlen=strr.length;
	if(strlen!=16 || strlen!=15)
	{
		alert(msg);
		str.focus();
		return false;
	}
	return true;
}

function chkcardno16(str,msg)
{	
	var strr=str.value;
	var strlen=strr.length;
	if(strlen!=16)
	{
		alert(msg);
		str.focus();
		return false;
	}
	return true;
}

//Enter Password with Minimum 6 Characters
//if (!chkstrlen(dom.password,"Enter Password with Minimum 6 Characters")) {  return false; }
function chkstrlen(str,msg)
{	
	var strr=str.value;
	var strlen=strr.length;
	alert(strr.length);
	if(strlen<6)
	{
		alert(msg);
		str.focus();
		return false;
	}
	return true;
}


function checkext(strpassed)
{

		var strr=strpassed.value
		
		var lenstrn=strr.length;
		strextn=strr.substr(lenstrn-4)
		strextn=strextn.toUpperCase();
		
		if(strextn!='JPEG' && strextn!='.JPG' && strextn!='.GIF' && strextn!='.PNG' )
		{
			alert("Format of files allowed to upload: GIF, JPEG OR PNG");
			strpassed.focus();
			return false;			
		}	
		
		return true;
}

function trim(inputString) {
   // Removes leading and trailing spaces from the passed string. Also removes
   // consecutive spaces and replaces it with one space. If something besides
   // a string is passed in (null, custom object, etc.) then return the input.
   if (typeof inputString != "string") { return inputString; }
   var retValue = inputString;
   var ch = retValue.substring(0, 1);
   while (ch == " ") { // Check for spaces at the beginning of the string
      retValue = retValue.substring(1, retValue.length);
      ch = retValue.substring(0, 1);
   }
   ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") { // Check for spaces at the end of the string
      retValue = retValue.substring(0, retValue.length-1);
      ch = retValue.substring(retValue.length-1, retValue.length);
   }
   while (retValue.indexOf(" ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
      retValue = retValue.substring(0, retValue.indexOf(" ")) + retValue.substring(retValue.indexOf(" ")+1, retValue.length); // Again, there are two spaces in each of the strings
   }
   return retValue; // Return the trimmed string back to the user
} // Ends the "trim" function

function msg(msg)
{
	
	alert(msg);
}

/*function emailcheck(email) 	                                        
{                                                                       
	                                                                
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{     
		alert("Enter Valid Email containing @ and .");	
		return false;                                           
	}                                                               
	return true;                                                    
} 
*/

function isFloat(s) 
{
		if(!s.match(/^\d{0,10}[.]{0,1}\d{0,2}$/))
			return false;
		else
			return true ;
}

function isNumber(s) 
{
	if(s.match(/^\d{0,10}$/) && s <= 2147483647)
		return true;		
	else
		return false ;
}

function checknull(Obj,Msg)
{
	if (trim(Obj.value)=="")
		{
			msg(Msg);
			Obj.focus();
			return false;
		}
	else
		{
			return true;
		}
}

function checkoption(Obj,Msg)
{
	if (trim(Obj.options[Obj.selectedIndex].value)=="")
		{
			msg(Msg);
			Obj.focus();
			return false;
		}
		else
		{
			return true;
		}
}

function statustxt(val)
{
// onMouseDown="return statustxt('<? echo $ChildLinkTitle?>')" onMouseMove="return statustxt('<? echo $ChildLinkTitle?>')" onMouseOut="return statustxt('<? echo $ChildLinkTitle?>')" onMouseUp="return statustxt('<? echo $ChildLinkTitle?>')" onMouseOver="return statustxt('<? echo $ChildLinkTitle?>')"
  status=val;
  return true;

}

function emailcheck(email)
{
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
	{
		return false;
	}
	return true;
}

function IsNumeric(num)
{
	var filter = /[^0-9]/;
	return !filter.test(num);
	
}
function isblank(s)
{
	for(var i=0; i < s.length; i++)
	{
		var c = s.charAt(i);
		
		if((c != ' ') && (c != '\n') && (c != '\t'))
			return false;
	}
	return true;
}
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}


function xmlhttpPost(strURL,t,val) {
	
    var xmlHttpReq = false;
    var self = this;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        self.xmlHttpReq = new XMLHttpRequest();
    }
    // IE
    else if (window.ActiveXObject) {
        self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
	
	if(t==1)
	{
		if(val=="")
		{
			alert("Please Login to Add this promotion to Your favorite list");
			return false;
		}
		else
		{
			val1="&uid="+val;
		}
	}
	
	//alert(strURL+val1);
	self.xmlHttpReq.open('POST', strURL+val1, true);
    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    
	self.xmlHttpReq.onreadystatechange = function() 
    {	
		if (self.xmlHttpReq.readyState == 4) {
			//alert(self.xmlHttpReq.responseText);
            updatepage(self.xmlHttpReq.responseText,t);
        }
    }
    self.xmlHttpReq.send(null);
}

function updatepage(str,s)
{
	if(s==1)
	{
		alert(str);
	}

}