// JScript File

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) var a;//alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function chk(strFields)
{
    var e=document.getElementById("chkTermsAgreement");
    if(e.checked)
    {
        if(strFields!=""){
            if(dispAlert(strFields)){
                return true;
            }else{
                return false;
            }
        }else{
            return true;
        }
    }
    else
    {
        alert("You must agree to terms to continue");
        return false;
    }
}

function deactivateState()
{
    var x=document.getElementById('drpCountry');
    if(x.options[x.selectedIndex].text=='United States')
        document.getElementById('drpState').disabled=false;
    else
        {
            document.getElementById('drpState').disabled=true;
            //document.getElementById('drpState').selectedIndex=-1;
        }
}
function checkCharacters(strVal){
	j_maj = strVal.length;
	validChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.+,<>#;?- @1234567890"\'&!=_-:/';
	for(i_maj=0; i_maj<j_maj; i_maj++){
		if (validChars.indexOf(strVal.charAt(i_maj))<0){
			i_maj=99;
			return true;
		}
	}	
	return false;	
}
function YY_checkform() { //v4.71
//copyright (c)1998,2002 Yaromat.com
  var a=YY_checkform.arguments,oo=true,v='',s='',err=false,r,o,at,o1,t,i,j,ma,rx,cd,cm,cy,dte,at;
  for (i=1; i<a.length;i=i+4){
    if (a[i+1].charAt(0)=='#'){r=true; a[i+1]=a[i+1].substring(1);}else{r=false}
	//alert(a[i]);
    o=MM_findObj(a[i].replace(/\[\d+\]/ig,""));
    o1=MM_findObj(a[i+1].replace(/\[\d+\]/ig,""));
	//alert(a[i] + "\n" + a[i+1]);
    v=o.value;t=a[i+2];
    validChar=false;
    if ((o.type=='text'||o.type=='password'||o.type=='hidden') &&(t!=8)){
      if (r&&v.length==0){err=true}
	  if(checkCharacters(v)){
		  err=true;	
		  validChar=true;
	  }
      if (v.length>0)
      if (t==1){ //fromto
        ma=a[i+1].split('_');if(isNaN(v)||v<ma[0]/1||v > ma[1]/1){err=true}
      } else if (t==2){
        rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-zA-Z]{2,4}$");if(!rx.test(v))err=true;
      } else if (t==3){ // date
        ma=a[i+1].split("#");at=v.match(ma[0]);
        if(at){
          cd=(at[ma[1]])?at[ma[1]]:1;cm=at[ma[2]]-1;cy=at[ma[3]];
          dte=new Date(cy,cm,cd);
          if(dte.getFullYear()!=cy||dte.getDate()!=cd||dte.getMonth()!=cm){err=true};
        }else{err=true}
      } else if (t==4){ // time
        ma=a[i+1].split("#");at=v.match(ma[0]);if(!at){err=true}
      } else if (t==5){ // check this 2
            if(o1.length)o1=o1[a[i+1].replace(/(.*\[)|(\].*)/ig,"")];
            if(!o1.checked){err=true}
      } else if (t==6){ // the same
            if(v!=MM_findObj(a[i+1]).value){err=true}
      } else if(t==7){ // Execute function with object's value as a parameter
    	  
	  	var arrFunc = a[i+1].split('#');
	  	//alert(a[i+1] + "-" + arrFunc);
	  	if(arrFunc[1]!=""){
			eval("var resDynamicCall = "+arrFunc[1]+"('"+v+"')");
			//alert(resDynamicCall);
			if(resDynamicCall.length>0){ err=true;a[i+3]=resDynamicCall; }else{ }
		}
	  }
    } 
	else if (!o.type&&o.length>0&&o[0].type=='radio'){
          at = a[i].match(/(.*)\[(\d+)\].*/i);
          o2=(o.length>1)?o[at[2]]:o;
      if (t==1&&o2&&o2.checked&&o1&&o1.value.length/1==0){err=true}
      else if (t==2){
        oo=false;
        for(j=0;j<o.length;j++){oo=oo||o[j].checked}
        if(!oo){s+='* '+a[i+3]+'\n'}
      }
	  else if(t==7){ // Execute function with object's value as a parameter
    	  
	  	var arrFunc = a[i+1].split('#');
	  	//alert(a[i+1] + "-" + arrFunc);
	  	if(arrFunc[1]!=""){
			eval("var resDynamicCall = "+arrFunc[1]+"('"+v+"')");
			//alert(resDynamicCall);
			if(resDynamicCall.length>0){ err=true;a[i+3]=resDynamicCall; }else{ }
		}
	  }
    } 
	else if (o.type=='checkbox'){
      if((t==1&&o.checked==false)||(t==2&&o.checked&&o1&&o1.value.length/1==0)){err=true}
    } 
	else if (o.type=='select-one'||o.type=='select-multiple'){
      if(t==1&&o.selectedIndex/1==0){err=true}
	  else if(t==7){ // Execute function with object's value as a parameter
    	  
	  	var arrFunc = a[i+1].split('#');
	  	//alert(a[i+1] + "-" + arrFunc);
		if(arrFunc[0]=="q" && o.selectedIndex/1==0){
			err=true;
		}else if(arrFunc[1]!=""){
			if(arrFunc[2]==undefined){
				eval("var resDynamicCall = "+arrFunc[1]+"('"+v+"','"+o.name+"',0)");
			}else{
				eval("var resDynamicCall = "+arrFunc[1]+"('"+v+"','"+o.name+"'," +arrFunc[2]+ ")");
			}
			//alert(resDynamicCall);
			if(resDynamicCall.length>0){ err=true;a[i+3]= a[i+3] + resDynamicCall; }else{ }
		}
	  }
    }
	else if (o.type=='textarea'){
      if(v.length<a[i+1]){err=true}
    }
	else if (o.type=='file'){
		if (r&&v.length==0){err=true}
	}
	else if (o.type=='hidden' && t==8){
		var oEditor = FCKeditorAPI.GetInstance(o.name) ;
		editorVal = oEditor.GetXHTML( false );
		if(editorVal!=""){
		}else{
			err=true;
		}
	}
    if (err){
		extra_s = '';
		if(validChar) extra_s=' '+'Must be Valid Characters...';
		s+='* '+a[i+3]+extra_s+'\n'; 
		err=false;
	}
  }
  if (s!=''){alert('The required information is incomplete or contains errors:\t\t\t\t\t\n\n'+s)}
  document.MM_returnValue = (s=='');
}

/*
function toggle(objnm)
{
	//alert(document.getElementById(objnm).style.display);
	if(document.getElementById(objnm).style.display	=='none')
	{
		document.getElementById(objnm).style.display='block';
		//document.getElementById("btn"+objnm).value='«';
	}
	else
	{
		document.getElementById(objnm).style.display='none';
		//document.getElementById("btn"+objnm).value='»';
	}
}

function validateZIP(field) 
{
    var valid = "0123456789-";
    var hyphencount = 0;

    if (field.length!=5 && field.length!=10) 
    {
        //alert("Please enter your 5 digit or 5 digit+4 zip code.");
        return false;
    }
    for (var i=0; i < field.length; i++) 
    {
        temp = "" + field.substring(i, i+1);
        if (temp == "-") hyphencount++;
        if (valid.indexOf(temp) == "-1") 
        {
            //alert("Invalid characters in your zip code.  Please try again.");
            return false;
        }
        if ((hyphencount > 1) || ((field.length==10) && ""+field.charAt(5)!="-")) 
        {
            //alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
            return false;
        }
    }
return true;
}

function CalcKeyCode(aChar) {
  var character = aChar.substring(0,1);
  var code = aChar.charCodeAt(0);
  return code;
}

function checkNumber(val)
{
  var strPass = val.value;
  var strLength = strPass.length;
  for(i=0;i<strLength;i++)
  {
      var lchar = val.value.charAt(i);
      var cCode = CalcKeyCode(lchar);
      if (cCode < 48 || cCode > 57 )
      {
        return false;
      }
  }
  return true;
}

// returns true if the string is a US phone number formatted as...
// (000)000-0000, (000) 000-0000, 000-000-0000, 000.000.0000, 000 000 0000, 0000000000
function isPhoneNumber(str)
{
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/
  return re.test(str);
}


function checkBox(subjects)
{
    var Sub=subjects.split(',');
    var chkNo;
    for(i=0;i<Sub.length;i++)
    {
        if(Sub[i]!="")
        {
            if(Sub[i]>25)
            {
                Sub[i]=Sub[i]-26;
                chkNo=2;
            }
            else
            {
                Sub[i]=Sub[i]-1;
                chkNo=1;
            }
            //alert('chkSubjects'+chkNo+'_'+Sub[i]);
            document.getElementById('chkSubjects'+chkNo+'_'+Sub[i]).checked=true;
        }
    }
}

function checkDate(){
    var rdObj;
    rdObj = document.getElementById("chkUnpublish");
    dateObj = document.getElementById("txtPublicationDate");
    btnObj = document.getElementById("btnContinue");
    if(rdObj.checked){
        dateObj.value="";
        btnObj.onclick = function() {
            return dispAlert('txtPublisherName,txtStreet1,txtCity,txtZipCode,txtTelephone,txtFax,txtEmail,txtCoordinatorName,txtCoordinatorTitle,txtCoordinatorTelephone,txtRightsCntTelephone,txtStrtYearPublishing,txtTitle,txtCopyrightYear,txtNoOfPages,txtBookSize,txtLanguage,txtRetailPrice,txtAge,txtContributor,txtContributorTitle');
        }
    }else{
        btnObj.onclick = function() {
            return dispAlert('txtPublisherName,txtStreet1,txtCity,txtZipCode,txtTelephone,txtFax,txtEmail,txtCoordinatorName,txtCoordinatorTitle,txtCoordinatorTelephone,txtRightsCntTelephone,txtStrtYearPublishing,txtTitle,txtPublicationDate,txtCopyrightYear,txtNoOfPages,txtBookSize,txtLanguage,txtRetailPrice,txtAge,txtContributor,txtContributorTitle');
        }
    }
}

function move(fbox, tbox) {
     var arrFbox = new Array();
     var arrTbox = new Array();
     var arrLookup = new Array();
     var i;
     for(i=0; i<tbox.options.length; i++) {
          arrLookup[tbox.options[i].text] = tbox.options[i].value;
          arrTbox[i] = tbox.options[i].text;
     }
     var fLength = 0;
     var tLength = arrTbox.length
     for(i=0; i<fbox.options.length; i++) {
          arrLookup[fbox.options[i].text] = fbox.options[i].value;
          if(fbox.options[i].selected && fbox.options[i].value != "") {
               arrTbox[tLength] = fbox.options[i].text;
               tLength++;
          } else {
               arrFbox[fLength] = fbox.options[i].text;
               fLength++;
          }
     }
     arrFbox.sort();
     arrTbox.sort();
     fbox.length = 0;
     tbox.length = 0;
     var c;
     for(c=0; c<arrFbox.length; c++) {
          var no = new Option();
          no.value = arrLookup[arrFbox[c]];
          no.text = arrFbox[c];
          fbox[c] = no;
     }
     for(c=0; c<arrTbox.length; c++) {
     	var no = new Option();
     	no.value = arrLookup[arrTbox[c]];
     	no.text = arrTbox[c];
     	tbox[c] = no;
     }
}

function selectAll(box) {
     for(var i=0; i<box.length; i++) {
     	box[i].selected = true;
     }
}               

function setClientData(strCustomerID){
	FireBasicAjaxRequest('type=getDetail&customerID='+strCustomerID, 'admin/customer.php','div_status');
	return false;
}

function check4UploadField(val){
	//alert(val);
	try{
		if((val!="") && (!isNaN(val)) && (val>0)){
			document.getElementById("tr_upload").style.display = "";	
		}else{
			document.getElementById("tr_upload").style.display = "none";		
		}
	}catch(ex){
	}
}
function checkSendAssignment(cntChk){
	var arrChecked = Array();
	cntArr = 0;
	for(c=1;c<=cntChk;c++){
		var chkStatus = document.getElementById('chk_'+c);
		if (chkStatus.checked){
			arrChecked[cntArr] = chkStatus.value;
			cntArr++;
		}
	}
	strChecked = arrChecked.join(",");
	if (strChecked!=""){
		FireAjaxRequest('type=sendAssignment&isbnID='+strChecked, 'admin/isbn_assignment.php','div_list','div_status','block');
	}else{
		alert("Please select ISBN to send...");
		return false;
	}
	
}
function checkISBNValidation(strISBN){
	strISBN = strISBN.replace(/-/g,'');
	if (strISBN.length==13){
		var arr = strISBN.match(/\d{13}/);
		if (arr.length>0){
			sum12 = 0;
			for (i=0;i<strISBN.length-1;i++){
				var charInd = strISBN.charAt(i);
				if ((i%2)==0){
					sum12 = parseInt(sum12) + (parseInt(charInd)*1);
				}else{
					sum12 = parseInt(sum12) + (parseInt(charInd)*3);	
				}
			}
			//alert(sum12);
			checkSum = 10 - (parseInt(sum12) %10);
			if(parseInt(checkSum)==10) checkSum = 0;
			if(checkSum==parseInt(strISBN.charAt(strISBN.length-1))){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}else{
		return false;
	}
}*/

function addLoadEvent(func) { 
  //alert("add");
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function() { 
      if (oldonload) { 
        oldonload(); 
      } 
      func(); 
    } 
  } 
} 
/*
function showPrint(){
	arr = document.getElementsByName("chkOrder");
	chkID = Array();
	for(i=0;i<arr.length;i++){
		if(arr[i].checked){
			chkID[chkID.length]=arr[i].value;
		}
	}
	if((chkID.length==1) && (document.getElementById("certificate_id").value!="")){
		window.open("printOrder.php?id="+chkID.join(",")+"&certificate_id="+document.getElementById("certificate_id").value,"PrintOrder","scrollbars=yes,status=no,menubar=no,height=600,width=700");
	}else{
		alert("Please Select only 1 order & Certificate to print");
		return false;
	}
	/*if(chkID.length>3){
		alert("Please select upto 3 orders to fit in single page");
	}else{
		if((chkID.length>=1) && (chkID.length<=3)){
			window.open("printOrder.php?id="+chkID.join(","),"PrintOrder","scrollbars=yes,status=no,menubar=no,height=600,width=700");
		}else{
			alert("Please select atleas 1 order to Print...");
		}
	}* /	
}
function findPosX(obj)
{
    var curleft = 0;
    if (obj.offsetParent)
    {
        while (obj.offsetParent)
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}
function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}


function saveXY(){
	document.getElementById("hidden_div_1").value = findPosX(document.getElementById("div_1"))+","+findPosY(document.getElementById("div_1"));
	document.getElementById("hidden_div_2").value = findPosX(document.getElementById("div_2"))+","+findPosY(document.getElementById("div_2"));
	document.getElementById("hidden_div_3").value = findPosX(document.getElementById("div_3"))+","+findPosY(document.getElementById("div_3"));
	//alert(document.getElementById("hidden_div_1").value);
	//alert(document.getElementById("hidden_div_2").value);
	//alert(document.getElementById("hidden_div_3").value);
	return true;
}
*/
function addtoCart(serID){
	//alert(serID);
	FireAjaxRequest("action=add&id="+serID, "myCart.php","divMyCart","divStatus","block");
}
function removefromCart(serID){
	//alert(serID);
	FireAjaxRequest("action=remove&id="+serID, "myCart.php","divMyCart","divStatus","block");
}
function displayCapper(capperID){
	divName = "capper_"+capperID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("capperID="+capperID,"capperRandom.php",divName,divName+"_status","block");
}
function displayPick(pickID){
	divName = "pick_"+pickID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("pickID="+pickID,"capperRandom.php",divName,divName+"_status","block");
}
function displayService(serviceID){
	divName = "service_"+serviceID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("serviceID="+serviceID,"capperRandom.php",divName,divName+"_status","block");
}
function displayAllAccess(accessPassID){
	divName = "div_AllAccess"+accessPassID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("all_access_id="+accessPassID,"capperRandom.php",divName,divName+"_status","block");
}

function displayToutBox(capperID){
	divName = "div_TB"+capperID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("tout_capper_id="+capperID,"capperRandom.php",divName,divName+"_status","block");
}

function displayAnyCapper(accessPassID){
	divName = "div_AnyCapper"+accessPassID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("all_access_id="+accessPassID,"capperRandom.php",divName,divName+"_status","block");
}

function getRecords(strType,member_id,capper_id){
	if(strType==""){
		buttonGroup[0].checked = true;
		strType = "S";
	}
	FireAjaxRequest("type=manage_service_pre&capperID="+capper_id+"&member_id="+member_id+"&displayType="+strType,"admin/member.php","div_my_ser_add","div_my_ser_status","block");
}

function getSelectedRadio(bG) {
   buttonGroup = document.getElementsByName(bG); 
   // returns the array number of the selected radio button or -1 if no button is selected
   if (buttonGroup[0]) { // if the button group is an array (one button is not an array)
      for (var i=0; i<buttonGroup.length; i++) {
         if (buttonGroup[i].checked) {
            return i
         }
      }
   } else {
      if (buttonGroup.checked) { return 0; } // if the one button is checked, return zero
   }
   // if we get to this point, no radio button is selected
   return -1;
} // Ends the "getSelectedRadio" function

function getSelectedRadioValue(bG) {
	buttonGroup = document.getElementsByName(bG); 
   // returns the value of the selected radio button or "" if no button is selected
   var i = getSelectedRadio(bG);
   if (i == -1) {
      return "";
   } else {
      if (buttonGroup[i]) { // Make sure the button group is an array (not just one button)
         return buttonGroup[i].value;
      } else { // The button group is just the one button, and it is checked
         return buttonGroup.value;
      }
   }
} // Ends the "getSelectedRadioValue" function

function displayRandomContent(grpID){
	divName = "myRandomID"+grpID;
	document.write("<div id='"+divName+"'></div>");
	document.write("<div id='"+divName+"_status'></div>");		
	FireAjaxRequest("group_id="+grpID,"randomContent.php",divName,divName+"_status","block");
}

//CC Validation
var Cards = new makeArray(8);
Cards[0] = new CardType("MasterCard", "51,52,53,54,55", "16");
var MasterCard = Cards[0];
Cards[1] = new CardType("VisaCard", "4", "13,16");
var VisaCard = Cards[1];
Cards[2] = new CardType("AmExCard", "34,37", "15");
var AmExCard = Cards[2];
Cards[3] = new CardType("DinersClubCard", "30,36,38", "14");
var DinersClubCard = Cards[3];
Cards[4] = new CardType("DiscoverCard", "6011", "16");
var DiscoverCard = Cards[4];
Cards[5] = new CardType("enRouteCard", "2014,2149", "15");
var enRouteCard = Cards[5];
Cards[6] = new CardType("JCBCard", "3088,3096,3112,3158,3337,3528", "16");
var JCBCard = Cards[6];
var LuhnCheckSum = Cards[7] = new CardType();

/*************************************************************************\
CheckCardNumber(form)
function called when users click the "check" button.
\*************************************************************************/
function CheckCardNumber(val) {
var tmpyear;
CN = document.getElementById("txtCardNumber");
EY = document.getElementById("drpYear");
EM = document.getElementById("drpMonth");
CT = document.getElementById("drpCType");
if (CN.value.length == 0) {
	CN.focus();
	return "Please enter a Card Number.";
}
if (EY.value=="") {
	EY.focus();
	return "Please enter the Expiration Year.";
}
/*if (form.ExpYear.value > 96)
tmpyear = "19" + form.ExpYear.value;
else if (form.ExpYear.value < 21)
tmpyear = "20" + form.ExpYear.value;
else {
alert("The Expiration Year is not valid.");
return;
}*/
tmpyear = EY.options[EY.selectedIndex].value;
tmpmonth = EM.options[EM.selectedIndex].value;
// The following line doesn't work in IE3, you need to change it
// to something like "(new CardType())...".
// if (!CardType().isExpiryDate(tmpyear, tmpmonth)) {
if (!(new CardType()).isExpiryDate(tmpyear, tmpmonth)) {
	return "This card has already expired.";
}
card = CT.options[CT.selectedIndex].value;
var retval = eval(card + ".checkCardNumber(\"" + CN.value + "\", " + tmpyear + ", " + tmpmonth + ");");
cardname = "";
if (retval)
	// comment this out if used on an order form
	return true;
else {
	// The cardnumber has the valid luhn checksum, but we want to know which
	// cardtype it belongs to.
	for (var n = 0; n < Cards.size; n++) {
		if (Cards[n].checkCardNumber(CN.value, tmpyear, tmpmonth)) {
			cardname = Cards[n].getCardType();
			break;
		}
	}
	if (cardname.length > 0) {
		return "This looks like a " + cardname + " number, not a " + card + " number.";
	}
	else {
		return "This card number is not valid.";
	}
   }
}
/*************************************************************************\
Object CardType([String cardtype, String rules, String len, int year, 
                                        int month])
cardtype    : type of card, eg: MasterCard, Visa, etc.
rules       : rules of the cardnumber, eg: "4", "6011", "34,37".
len         : valid length of cardnumber, eg: "16,19", "13,16".
year        : year of expiry date.
month       : month of expiry date.
eg:
var VisaCard = new CardType("Visa", "4", "16");
var AmExCard = new CardType("AmEx", "34,37", "15");
\*************************************************************************/
function CardType() {
var n;
var argv = CardType.arguments;
var argc = CardType.arguments.length;

this.objname = "object CardType";

var tmpcardtype = (argc > 0) ? argv[0] : "CardObject";
var tmprules = (argc > 1) ? argv[1] : "0,1,2,3,4,5,6,7,8,9";
var tmplen = (argc > 2) ? argv[2] : "13,14,15,16,19";

this.setCardNumber = setCardNumber;  // set CardNumber method.
this.setCardType = setCardType;  // setCardType method.
this.setLen = setLen;  // setLen method.
this.setRules = setRules;  // setRules method.
this.setExpiryDate = setExpiryDate;  // setExpiryDate method.

this.setCardType(tmpcardtype);
this.setLen(tmplen);
this.setRules(tmprules);
if (argc > 4)
this.setExpiryDate(argv[3], argv[4]);

this.checkCardNumber = checkCardNumber;  // checkCardNumber method.
this.getExpiryDate = getExpiryDate;  // getExpiryDate method.
this.getCardType = getCardType;  // getCardType method.
this.isCardNumber = isCardNumber;  // isCardNumber method.
this.isExpiryDate = isExpiryDate;  // isExpiryDate method.
this.luhnCheck = luhnCheck;// luhnCheck method.
return this;
}

/*************************************************************************\
boolean checkCardNumber([String cardnumber, int year, int month])
return true if cardnumber pass the luhncheck and the expiry date is
valid, else return false.
\*************************************************************************/
function checkCardNumber() {
var argv = checkCardNumber.arguments;
var argc = checkCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
var year = (argc > 1) ? argv[1] : this.year;
var month = (argc > 2) ? argv[2] : this.month;

this.setCardNumber(cardnumber);
this.setExpiryDate(year, month);

if (!this.isCardNumber())
return false;
if (!this.isExpiryDate())
return false;

return true;
}
/*************************************************************************\
String getCardType()
return the cardtype.
\*************************************************************************/
function getCardType() {
return this.cardtype;
}
/*************************************************************************\
String getExpiryDate()
return the expiry date.
\*************************************************************************/
function getExpiryDate() {
return this.month + "/" + this.year;
}
/*************************************************************************\
boolean isCardNumber([String cardnumber])
return true if cardnumber pass the luhncheck and the rules, else return
false.
\*************************************************************************/
function isCardNumber() {
var argv = isCardNumber.arguments;
var argc = isCardNumber.arguments.length;
var cardnumber = (argc > 0) ? argv[0] : this.cardnumber;
if (!this.luhnCheck())
return false;

for (var n = 0; n < this.len.size; n++)
if (cardnumber.toString().length == this.len[n]) {
for (var m = 0; m < this.rules.size; m++) {
var headdigit = cardnumber.substring(0, this.rules[m].toString().length);
if (headdigit == this.rules[m])
return true;
}
return false;
}
return false;
}

/*************************************************************************\
boolean isExpiryDate([int year, int month])
return true if the date is a valid expiry date,
else return false.
\*************************************************************************/
function isExpiryDate() {
var argv = isExpiryDate.arguments;
var argc = isExpiryDate.arguments.length;

year = argc > 0 ? argv[0] : this.year;
month = argc > 1 ? argv[1] : this.month;

if (!isNum(year+""))
return false;
if (!isNum(month+""))
return false;
today = new Date();
expiry = new Date(year, month);
if (today.getTime() > expiry.getTime())
return false;
else
return true;
}

/*************************************************************************\
boolean isNum(String argvalue)
return true if argvalue contains only numeric characters,
else return false.
\*************************************************************************/
function isNum(argvalue) {
argvalue = argvalue.toString();

if (argvalue.length == 0)
return false;

for (var n = 0; n < argvalue.length; n++)
if (argvalue.substring(n, n+1) < "0" || argvalue.substring(n, n+1) > "9")
return false;

return true;
}

/*************************************************************************\
boolean luhnCheck([String CardNumber])
return true if CardNumber pass the luhn check else return false.
Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
\*************************************************************************/
function luhnCheck() {
var argv = luhnCheck.arguments;
var argc = luhnCheck.arguments.length;

var CardNumber = argc > 0 ? argv[0] : this.cardnumber;

if (! isNum(CardNumber)) {
return false;
  }

var no_digit = CardNumber.length;
var oddoeven = no_digit & 1;
var sum = 0;

for (var count = 0; count < no_digit; count++) {
var digit = parseInt(CardNumber.charAt(count));
if (!((count & 1) ^ oddoeven)) {
digit *= 2;
if (digit > 9)
digit -= 9;
}
sum += digit;
}
if (sum % 10 == 0)
return true;
else
return false;
}

/*************************************************************************\
ArrayObject makeArray(int size)
return the array object in the size specified.
\*************************************************************************/
function makeArray(size) {
this.size = size;
return this;
}

/*************************************************************************\
CardType setCardNumber(cardnumber)
return the CardType object.
\*************************************************************************/
function setCardNumber(cardnumber) {
this.cardnumber = cardnumber;
return this;
}

/*************************************************************************\
CardType setCardType(cardtype)
return the CardType object.
\*************************************************************************/
function setCardType(cardtype) {
this.cardtype = cardtype;
return this;
}

/*************************************************************************\
CardType setExpiryDate(year, month)
return the CardType object.
\*************************************************************************/
function setExpiryDate(year, month) {
this.year = year;
this.month = month;
return this;
}

/*************************************************************************\
CardType setLen(len)
return the CardType object.
\*************************************************************************/
function setLen(len) {
// Create the len array.
if (len.length == 0 || len == null)
len = "13,14,15,16,19";

var tmplen = len;
n = 1;
while (tmplen.indexOf(",") != -1) {
tmplen = tmplen.substring(tmplen.indexOf(",") + 1, tmplen.length);
n++;
}
this.len = new makeArray(n);
n = 0;
while (len.indexOf(",") != -1) {
var tmpstr = len.substring(0, len.indexOf(","));
this.len[n] = tmpstr;
len = len.substring(len.indexOf(",") + 1, len.length);
n++;
}
this.len[n] = len;
return this;
}

/*************************************************************************\
CardType setRules()
return the CardType object.
\*************************************************************************/
function setRules(rules) {
// Create the rules array.
if (rules.length == 0 || rules == null)
rules = "0,1,2,3,4,5,6,7,8,9";
  
var tmprules = rules;
n = 1;
while (tmprules.indexOf(",") != -1) {
tmprules = tmprules.substring(tmprules.indexOf(",") + 1, tmprules.length);
n++;
}
this.rules = new makeArray(n);
n = 0;
while (rules.indexOf(",") != -1) {
var tmpstr = rules.substring(0, rules.indexOf(","));
this.rules[n] = tmpstr;
rules = rules.substring(rules.indexOf(",") + 1, rules.length);
n++;
}
this.rules[n] = rules;
return this;
}

function addPick(mID){
	var mC, mP, mU;
	mC = $MAJ("drp_choice_"+mID).value;
	mU = $MAJ("drp_unit_"+mID).value;
	try{
		mP = $MAJ("drp_point_"+mID).value;
	}catch(e){
		mP = 0;
	}
	var obj13Val;
	try{
		obj13Val = document.getElementById("drp_5001_"+mID).value;	
		
	}catch(e1){
		obj13Val = 0;
	}
	if(mC==""){
		alert("Please Select your choice for the matchup");	
		return false;
	}else{
		var obj11 = document.getElementById("drp_pm_"+mID);
		var obj12 = document.getElementById("drp_50_"+mID);
		var obj21 = document.getElementById("drp_250_"+mID);
		var obj22 = document.getElementById("drp_ou_"+mID);
		var obj31 = document.getElementById("drp_teaser_"+mID);
		var obj41 = document.getElementById("drp_pm2_"+mID);
		var obj42 = document.getElementById("drp_500_"+mID);
		var objR = document.getElementsByName("rdType_"+mID);
		val = getRadioValue(objR);
		if(val=="spread"){
			if(obj12.length>2){
				if((obj11.value!="") && (obj12.value!="")){
				}else{
					alert("Please Select both values for Spread");	
					return false;
				}
			}else{
				if((obj11.value!="") && (obj12.value!="") && ( (obj13Val>0) || (obj13Val<0) )){
				//if((obj11.value!="") && (obj12.value!="") && (obj13Val<501) && (obj13Val>-501)){
				//alert("comp");
				}else{
					//alert(obj13Val);
					alert("Please Select all values for Spread");	
					return false;
				}
			}
		}else if(val=="total"){
			if((obj21.value!="") && (obj22.value!="")){
			}else{
				alert("Please Select both values for Total");	
				return false;
			}
		}else if(val=="teaser"){
			if(obj12.length>2){
			if((obj11.value!="") && (obj12.value!="") && (obj21.value!="") && (obj22.value!="") && (obj31.value!="")){
			}else{
				alert("Please Select all values for Spread, Total & Teaser");	
				return false;
			}
			}
			else
			{
				//if((obj11.value!="") && (obj12.value!="") && (obj13Val<501) && (obj13Val>-501) && (obj21.value!="") && (obj22.value!="") && (obj31.value!="")){
				if((obj11.value!="") && (obj12.value!="") && ( (obj13Val>0) || (obj13Val<0) ) && (obj21.value!="") && (obj22.value!="") && (obj31.value!="")){
			}else{
				alert("Please Select all values for Spread, Total & Teaser");	
				return false;
			}
			}
		
		}else if(val=="moneyline"){	
			if((obj41.value!="") && (obj42.value!="")){
			}else{
				alert("Please Select both values for Moneyline");	
				return false;
			}
		}
		obj11Val = escape(obj11.value);
		if(obj11Val=="+"){
			obj11Val = "P";
		}
		obj41Val = escape(obj41.value);
		if(obj41Val=="+"){
			obj41Val = "P";
		}
		FireAjaxRequest("type=addPick&mID="+mID+"&drp_choice="+mC+"&drp_point="+mP+"&drp_unit="+mU+"&choice_type="+val+"&obj11="+obj11Val+"&obj12="+obj12.value+"&obj13="+obj13Val+"&obj21="+obj21.value+"&obj22="+obj22.value+"&obj31="+obj31.value+"&obj41="+obj41Val+"&obj42="+obj42.value,"ajax.php","span_"+mID,"span_"+mID,"block");
	}
}
function getRadioValue(rdName) {
	for (index=0; index < rdName.length; index++) {
		if (rdName[index].checked) {
			return rdName[index].value;
		}
	}
}

function setDropdown(val,id){	
	var obj13;
	try{
		obj13 = document.getElementById("drp_5001_"+id);	
	}catch(e1){
		obj13 = 0;
	}
	//alert(val);
	var obj11 = document.getElementById("drp_pm_"+id);
	var obj12 = document.getElementById("drp_50_"+id);
	//var obj13 = document.getElementById("drp_5001_"+id);
	var obj21 = document.getElementById("drp_250_"+id);
	var obj22 = document.getElementById("drp_ou_"+id);
	var obj31 = document.getElementById("drp_teaser_"+id);
	var obj41 = document.getElementById("drp_pm2_"+id);
	var obj42 = document.getElementById("drp_500_"+id);
	if(val=="spread"){
		obj11.disabled = false;	
		obj12.disabled = false;	
		obj13.disabled = false;	
		obj21.disabled = true;	
		obj22.disabled = true;	
		obj31.disabled = true;	
		obj41.disabled = true;	
		obj42.disabled = true;	
	}else if(val=="total"){
		obj11.disabled = true;	
		obj12.disabled = true;	
		obj13.disabled = true;
		obj21.disabled = false;	
		obj22.disabled = false;	
		obj31.disabled = true;	
		obj41.disabled = true;	
		obj42.disabled = true;	
	}else if(val=="teaser"){
		obj11.disabled = false;	
		obj12.disabled = false;	
		obj13.disabled = false;	
		obj21.disabled = false;	
		obj22.disabled = false;	
		obj31.disabled = false;	
		obj41.disabled = true;	
		obj42.disabled = true;	
	}else if(val=="moneyline"){
		obj11.disabled = true;	
		obj12.disabled = true;	
		obj13.disabled = true;
		obj21.disabled = true;	
		obj22.disabled = true;	
		obj31.disabled = true;	
		obj41.disabled = false;	
		obj42.disabled = false;	
	}
}

function addSubcribe(){
	YY_checkform('frmSubscribe','subTxtName','#q','0','Name Must Be Entered & Valid...','subTxtEmail','#S','2','Email Must Be Entered & Valid...','subTxtPass','#q','0','Password Must Be Entered & Valid...');
	if(document.MM_returnValue){
		strData = 'type=addSubscribe';
		strData += '&subTxtName='+document.getElementById("subTxtName").value;
		strData += '&subTxtEmail='+document.getElementById("subTxtEmail").value;
		strData += '&subTxtPass='+document.getElementById("subTxtPass").value;
		FireAjaxRequest(strData, 'ajax.php','divSubscribe','div_status','block');
		return false;	
	}
}

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "-";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
var maxDigitsInIPhoneNumber = 15;

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 trim(s)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("-")!=-1)bracket=bracket+1
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf("(")>bracket)return false
var brchr=strPhone.indexOf("(")
if(strPhone.indexOf("(")!=-1 && strPhone.charAt(brchr+2)!=")")return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber && s.length <= maxDigitsInIPhoneNumber);
}
function ValidateForm(strPhone){
	//var Phone=document.frmSample.txtPhone
	
	if ((strPhone==null)||(strPhone=="")){
		return "Please Enter your Phone Number";
		//Phone.focus()
		//return false
	}
	if (checkInternationalPhone(strPhone)==false){
		return "Please Enter a Valid Phone Number";
		//Phone.value=""
		//Phone.focus()
		//return false
	}
	return true
 }
 function ValidateFormCell(strCell){
	if ((strCell==null)||(strCell=="")){
		return "Please Enter your Cell Number";
	}
	if (checkInternationalPhone(strCell)==false){
		return "Please Enter a Valid Cell Number";
	}
	return true
 }
 
 function PackValidation(){
	objD = document.getElementById('pack_days_duration');
	objS = document.getElementById('pack_start_date');
	objE = document.getElementById('pack_end_date');
	if(objD.value == '' && objS.value == '' && objE.value == '')
	{
		return 'Please choose Either Days in Duration OR Start & End Date for Package.';
	}else if(objD.value == '' && (objS.value == '' || objE.value == '')){
		return 'Please select both Start & End Date for Package';
	}
	else if(objD.value != '' && (objD.value>0) && (objS.value != '' || objE.value != ''))
	{
		return 'Please choose Either Days in Duration OR Start & End Date for Package.';
	}
	else{
		return true;
	}
 }
 
 function checkMail(){
	 FireAjaxRequest("type=checkMail","ajax.php","spanMail","spanMail","");	
 }
 
 function refreshMenu(){
 	FireAjaxRequest("type=refreshMenu","ajax.php","nav","nav","");	
 }
 
 
function newClassified(){
	document.getElementById('div_classified').innerHTML = '';
	document.getElementById('div_clssedit').innerHTML = '';
	FireAjaxRequest("type=newClassified","ajax.php","div_clssadd","div_clssadd","block");
	return false;
}
function EDClassified(){
	document.getElementById('div_classified').innerHTML = '';
	FireAjaxRequest("type=EDClassified","ajax.php","div_clssadd","div_clssadd","block");
	return false;
}
function classifiedDelete(id){
	if(confirm('Are you want Delete selected classified?')){
		FireAjaxRequest("type=classifiedDelete&id="+id,"ajax.php","div_clssedit","div_clssedit","block");
	}
	
	return false;
}
function classifiedEdit(id){
document.getElementById('div_classified').innerHTML = '';
	FireAjaxRequest("type=classifiedEdit&id="+id,"ajax.php","div_clssedit","div_clssedit","block");
	return false;
}
			
function newNetwork(){
	document.getElementById('div_network').innerHTML = '';
	document.getElementById('div_netedit').innerHTML = '';
	FireAjaxRequest("type=newNetwork","ajax.php","div_netadd","div_netadd","block");
	return false;
}
function EDNetwork(){
	document.getElementById('div_network').innerHTML = '';
	FireAjaxRequest("type=EDNetwork","ajax.php","div_netadd","div_netadd","block");
	return false;
}
function netDelete(id){
	if(confirm('Are you want Delete selected Network?')){
		FireAjaxRequest("type=networkDelete&id="+id,"ajax.php","div_netedit","div_netedit","block");
	}
	
	return false;
}
function netEdit(id){
	document.getElementById('div_network').innerHTML = '';
	FireAjaxRequest("type=networkEdit&id="+id,"ajax.php","div_netedit","div_netedit","block");
	return false;
}
			
function newevent(){
	window.location.href= 'events/index.php?action=event_form';
	//document.getElementById('div_event').innerHTML = '';
	//document.getElementById('div_eventedit').innerHTML = '';
	//FireAjaxRequest("type=newevent","ajax.php","div_eventadd","div_eventadd","block");
	return false;
}
function EDevent(){
	document.getElementById('div_event').innerHTML = '';
	FireAjaxRequest("type=EDevent","ajax.php","div_eventadd","div_eventadd","block");
	return false;
}
function eventDelete(id){
	if(confirm('Are you want Delete selected Event?')){
		window.location.href= 'events/index.php?action=event_delete&eid[]='+id+'&confirm=1';
	}
	return false;
}
function eventEdit(id){
	window.location.href= 'events/index.php?action=event_form&eid='+id;
	//document.getElementById('div_event').innerHTML = '';
	//FireAjaxRequest("type=eventEdit&id="+id,"ajax.php","div_eventedit","div_eventedit","block");
	return false;
}
			
			
function newBlog(){
	document.getElementById('div_blog').innerHTML = '';
	document.getElementById('div_blogedit').innerHTML = '';
	FireAjaxRequest("type=newBlog","ajax.php","div_blogadd","div_blogadd","block");
	return false;
}
function EDBlog(){
	document.getElementById('div_blog').innerHTML = '';
	FireAjaxRequest("type=EDBlog","ajax.php","div_blogadd","div_blogadd","block");
	return false;
}
function blogDelete(id){
	if(confirm('Are you want Delete selected Blog?')){
		FireAjaxRequest("type=blogDelete&id="+id,"ajax.php","div_blogedit","div_blogedit","block");
	}
	
	return false;
}
function blogEdit(id){
	document.getElementById('div_blog').innerHTML = '';
	FireAjaxRequest("type=blogEdit&id="+id,"ajax.php","div_blogedit","div_blogedit","block");
	return false;
}
			
function addReply(id){
	FireAjaxRequest("type=addReply&id="+id,"ajax.php","cls_comments","cls_comments","block");
	return false;
}
function newLocator(){
	document.getElementById('div_locator').innerHTML = '';
	document.getElementById('div_lockedit').innerHTML = '';
	FireAjaxRequest("type=newLocator","ajax.php","div_lockadd","div_lockadd","block");
	return false;
}
function EDLocator(){
	document.getElementById('div_locator').innerHTML = '';
	FireAjaxRequest("type=EDLocator","ajax.php","div_lockadd","div_lockadd","block");
	return false;
}
function lockDelete(id){
	if(confirm('Are you want Delete selected Locator?')){
		FireAjaxRequest("type=lockDelete&id="+id,"ajax.php","div_lockedit","div_lockedit","block");
	}
	return false;
}
function lockEdit(id){
	document.getElementById('div_locator').innerHTML = '';
	FireAjaxRequest("type=lockEdit&id="+id,"ajax.php","div_lockedit","div_lockedit","block");
	return false;
}
			


function newContext(){
	document.getElementById('div_context').innerHTML = '';
	document.getElementById('div_contextedit').innerHTML = '';
	FireAjaxRequest("type=newContext","ajax.php","div_contextadd","div_contextadd","block");
	return false;
}
function EDContext(){
	document.getElementById('div_context').innerHTML = '';
	FireAjaxRequest("type=EDContext","ajax.php","div_contextadd","div_contextadd","block");
	return false;
}
function contextDelete(id){
	if(confirm('Are you want Delete selected Contextual Ad?')){
		FireAjaxRequest("type=contextDelete&id="+id,"ajax.php","div_contextedit","div_contextedit","block");
	}
	return false;
}
function contextEdit(id){
	document.getElementById('div_context').innerHTML = '';
	FireAjaxRequest("type=contextEdit&id="+id,"ajax.php","div_contextedit","div_contextedit","block");
	return false;
}


			
function newBanner(){
	document.getElementById('div_banner').innerHTML = '';
	document.getElementById('div_banneredit').innerHTML = '';
	FireAjaxRequest("type=newBanner","ajax.php","div_banneradd","div_banneradd","block");
	return false;
}
function EDBanner(){
	document.getElementById('div_banner').innerHTML = '';
	document.getElementById('div_banneredit').innerHTML = '';
	FireAjaxRequest("type=EDBanner","ajax.php","div_banneradd","div_banneradd","block");
	return false;
}
function bannerDelete(id){
	if(confirm('Are you want Delete selected Banner?')){
		FireAjaxRequest("type=bannerDelete&id="+id,"ajax.php","div_banneredit","div_banneredit","block");
	}
	return false;
}
function bannerEdit(id){
	document.getElementById('div_banner').innerHTML = '';
	FireAjaxRequest("type=bannerEdit&id="+id,"ajax.php","div_banneredit","div_banneredit","block");
	return false;
}
function RenewDetail(id,val,div){
	//alert(val);
	FireAjaxRequest("type=RenewDetail&id="+id+"&strval="+val,"ajax.php",div,div,"block");
	return false;
}
function RenewC(id,val,div){
	if(document.getElementById('rtype1').checked){
		rtype = 'FULL';
	}else if(document.getElementById('rtype2').checked){
		rtype = 'WEEK';
	}
	else if(document.getElementById('rtype3').checked){
		rtype = 'MONTH';
	}
	//alert(rtype);
	FireAjaxRequest("type=Renew&id="+id+"&strval="+val+"&rtype="+rtype,"ajax.php",div,div,"block");
	return false;
}	

function RenewB(id,val,div){
	
	rtype = document.getElementById('banner_infoR').value;
	FireAjaxRequest("type=Renew&id="+id+"&strval="+val+"&rtype="+rtype,"ajax.php",div,div,"block");
	return false;
}

function RenewN(id,val,div){
	
	rtype = document.getElementById('rntype').value;
	
	FireAjaxRequest("type=Renew&id="+id+"&strval="+val+"&rtype="+rtype,"ajax.php",div,div,"block");
	return false;
}

function Renew(id,val,div){
	FireAjaxRequest("type=Renew&id="+id+"&strval="+val,"ajax.php",div,div,"block");
	return false;
}

function makeoffer(){
	var a = YY_checkform('frmoffer','myoffer','1','1','Please enter your offer.');
	if(document.MM_returnValue){
		vs = getFormValues("frmoffer");
		FireAjaxRequest(vs,"ajax.php","div_offer","div_offer","block");
	}
	return false;
}
function postReply(){
	var a = YY_checkform('frmrply','blog_replies_comment','1','1','Reply is not valid.');
	if(document.MM_returnValue){
		vs = getFormValues("frmrply");
		FireAjaxRequest(vs,"ajax.php","div_comment","div_comment","block");
	}
	return false;
}
function makearea(val){
	$("#trText").hide();
	$("#trBanner").hide();	
	$("#trBannerType").hide();	
	$("#trBannerURL").hide();	
	$("#trTextType").hide();	
	if(val!="" || val!=undefined){
		$("#tr"+val).show();
		$("#tr"+val+"Type").show();
		if(val=="Banner"){
			$("#trBannerURL").show();	
		}
	}
	return false;
}
function checkValidation(){
	val = $("#ad_newsletter_type").val();
	if(val=="Text"){
		YY_checkform('frmaddnews','texttype','#q','1','Type is not valid.','ad_newsletter_type','#q','1','Select Ad Type','ad_newsletter_text','1','1','Enter Newsletter Ad Text');
	}else{
		//'ad_newsletter_url','#q','0','Enter Banner URL.',
		YY_checkform('frmaddnews','bannertype','#q','1','Type is not valid.','ad_newsletter_type','#q','1','Select Ad Type');
	}
	return document.MM_returnValue;
}
function newNews(){
	document.getElementById('div_newsedit').innerHTML = '';
	FireAjaxRequest("type=newNews","ajax.php","div_newsadd","div_newsadd","block");
	return false;
}
function EDNews(){
	document.getElementById('div_newsedit').innerHTML = '';
	FireAjaxRequest("type=EDNews","ajax.php","div_newsadd","div_newsadd","block");
	return false;
}
function newsDelete(id){
	if(confirm('Are you want Delete selected ad?')){
		FireAjaxRequest("type=newsDelete&id="+id,"ajax.php","div_newsedit","div_newsedit","block");
	}
	return false;
}
function bannerEdit1(id){
	document.getElementById('div_banner').innerHTML = '';
	FireAjaxRequest("type=bannerEdit&id="+id,"ajax.php","div_banneredit","div_banneredit","block");
	return false;
}

function EDBlogPost(){
	FireAjaxRequest("type=EDBlogPost","ajax.php","div_BlogPost","div_BlogPost","block");
	return false;
}
function EDBlogReply(){
	FireAjaxRequest("type=EDBlogReply","ajax.php","div_BlogReply","div_BlogReply","block");
	return false;
	
}
function blogView(id){
	FireAjaxRequest("type=blogView&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function ReplyView(id){
	FireAjaxRequest("type=ReplyView&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function blogApprove(id){
		//alert(id);
		FireAjaxRequest("type=blogApprove&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function blogReject(id){
		//alert(id);
		FireAjaxRequest("type=blogReject&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function replyApprove(id){
		//alert(id);
		FireAjaxRequest("type=replyApprove&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function replyReject(id){
		//alert(id);
		FireAjaxRequest("type=replyReject&id="+id,"ajax.php","div_BlogView","div_BlogView","block");
	return false;
}
function getCalc(valE,val){
	strE = "span"+valE;
	jsE = new ctlSpiffyCalendarBox('jsE','frmblogedit',valE,'btnDate1',val);
	jsE.dateFormat='MM/dd/yyyy';
	jsE.readonly=true;
	document.getElementById(strE).innerHTML = jsE.writeControl(true);
	return false;
}
function checkWord(val){
	if((val.split(' ')).length > 3){
		return "Please Enter up to 3 words.";
	}else{
		//FireAjaxRequest("type=ALertMSG&val="+val,"ajax.php","div_contextedit","div_contextedit","block","N","return document.getElementById('div_contextedit').innerHTML");
	}
	return false;
}

function checkurl(val){
	 ///http:\/\/
     var tomatch= /[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     if (tomatch.test(val)){}
     else{ return "URL is not valid";}
	 
	return false;
}

function GetAD(str){
	
	/*$(function () {
			  $('.bubbleInfo').each(function () {
				// options
				var distance = 10;
				var time = 250;
				var hideDelay = 500;
			
				var hideDelayTimer = null;
			
				// tracker
				var beingShown = false;
				var shown = false;
				
				var trigger = $('.trigger', this);
				var popup = $('.popup', this).css('opacity', 0);
			
				// set the mouseover and mouseout on both element
				$([trigger.get(0), popup.get(0)]).mouseover(function () {
				  // stops the hide event if we move from the trigger to the popup element
				  if (hideDelayTimer) clearTimeout(hideDelayTimer);
			
				  // don't trigger the animation again if we're being shown, or already visible
				  if (beingShown || shown) {
					return;
				  } else {
					beingShown = true;
			
					// reset position of popup box
					popup.css({
					  top: -100,
					  left: -33,
					  display: 'block' // brings the popup back in to view
					})
			
					// (we're using chaining on the popup) now animate it's opacity and position
					.animate({
					  top: '-=' + distance + 'px',
					  opacity: 1
					}, time, 'swing', function() {
					  // once the animation is complete, set the tracker variables
					  beingShown = false;
					  shown = true;
					});
				  }
				}).mouseout(function () {
				  // reset the timer if we get fired again - avoids double animations
				  if (hideDelayTimer) clearTimeout(hideDelayTimer);
				  
				  // store the timer so that it can be cleared in the mouseover if required
				  hideDelayTimer = setTimeout(function () {
					hideDelayTimer = null;
					popup.animate({
					  top: '-=' + distance + 'px',
					  opacity: 0
					}, time, 'swing', function () {
					  // once the animate is complete, set the tracker variables
					  shown = false;
					  // hide the popup entirely after the effect (opacity alone doesn't do the job)
					  popup.css('display', 'none');
					});
				  }, hideDelay);
				});
			  });
			});*/
		//return false;
}

/*function showClassified(strMD5,clsName,divID){
	//alert(divID);
	
	$("#"+clsName+"_"+divID).show("slow");
	$("#"+clsName+"_"+divID).html(status_innerHTML);
	$.get("classified_fulldetail.php", { md5ID: strMD5, ajaxBool: "true" },
   		function(data) {
			$("."+clsName).hide();
			$("#"+clsName+"_"+divID).html(data);
			$("#"+clsName+"_"+divID).show("slow");
     		//alert("Data Loaded: " + data);
   	});
	return false;
}*/


function showAJAXPAGE(strMD5,clsName,divID){
	if(clsName == 'divNetDetail'){
		page = "network_fulldetail.php";
	}
	if(clsName == 'divClassifiedDetail'){
		page = "classified_fulldetail.php";
	}
	if(clsName == 'divBlogDetail'){
		page = "blog_fulldetail.php";
	}
	if(clsName == 'divLockDetail'){
		page = "locator_detail.php";
	}
	if(clsName == 'divBlogDetail1'){
		page = "http://mi1/D/LaundryWizard/events/index.php?action=display_event&oid="+strMD5;
		//alert(page);
	}
	
	
	//
	
	$("#"+clsName+"_"+divID).show("slow");
	$("#"+clsName+"_"+divID).html(status_innerHTML);
	$.get(page, { md5ID: strMD5, ajaxBool: "true" },
   		function(data) {
			
			$("."+clsName).hide();
			$("#"+clsName+"_"+divID).html(data);
			$("#"+clsName+"_"+divID).show("slow");
     		//alert("Data Loaded: " + data);
   	});
	return false;
}
