﻿// JScript File
//*** general function used for all
var ctrl= "ctl00_ContentPlaceHolder1";
function trimAll(sString)
  {
    while (sString.substring(0,1) == ' ')
    {
    sString = sString.substring(1, sString.length);
    }
    while (sString.substring(sString.length-1, sString.length) == ' ')
    {
    sString = sString.substring(0,sString.length-1);
    }
    return sString;
  }
  function echeck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		   //alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Please enter a valid e-mail address.Some characters like @ or . was found to be missing");
		    return false
		 }
 		 return true					
	}
//function CheckEnter_Onclick(e,obj) 
//    { 
//    //alert(e);
//    //alert(btnobj);
//    var key; 
//    key=(e.which) ? e.which : e.keyCode; 
//    if(key==13) 
//    { 
//     document.getElementById(obj).focus();
//    } 
//    return true; 
//}

 
  
   
   
   
   
  
   
  
  
  
  
  //Globla function for cart statrs
  function OnBuySelectionCallback(objbuy,objval,objprce,objaddprce)
   {
     //alert('');
     document.getElementById(objval).innerHTML = '';
     var txt = document.createElement("OPTION");
     txt.text = "-select-";
     txt.value = 0;
     document.getElementById(objval).options.add(txt);
     
     var drp = objval;
     //alert(drp);
     //alert(document.getElementById(objbuy).selectedIndex);
     
         if (document.getElementById(objbuy).selectedIndex == 0) //Day
           {
               //alert('sss');
               binddrps(drp,6);
           }  
         else if(document.getElementById(objbuy).selectedIndex == 1) // Week
           {
               binddrps(drp,3);
           }
         else if(document.getElementById(objbuy).selectedIndex == 2)//Month
           {
              binddrps(drp,12);
           }
         else   //years //if (document.getElementById(objbuy).selectedIndex == 3
           {
              binddrps(drp,10);
           }
    document.getElementById(objprce).innerHTML = '$0';
    document.getElementById(objaddprce).innerHTML = 0;
   }
   function addOption(selectbox,text,value)
        {
            //alert(selectbox);
            //alert(text);
           // alert(value);
            var optn = document.createElement("OPTION");
            optn.text = text;
            optn.value = value;
            //alert(optn);
            //ctl00_ContentPlaceHolder1_drpuserspecializ
            selectbox.options.add(optn);
        }
   function binddrps(whichdrp,cntlen)
   {
    //alert(whichdrp);
    //alert(cntlen);
    for (var i=0 ; i < cntlen ; ++i)
      {
        //alert(i);
        addOption(document.getElementById(whichdrp),i+1,i+1)
        //addOption(whichdrp,i,i)
      }
   }
   function setwebinarPrice(drpobj,objprice,drpv,price1,price2,price3,price4,priceadd)
   {
     //alert(document.getElementById(drpobj).selectedIndex);
     //alert(objprice);
     var txtprice = document.getElementById(objprice);
     var txtaddprice = document.getElementById(priceadd);
     var drpbuyvalue = document.getElementById(drpv).selectedIndex
     var drp = document.getElementById(drpv);
     //alert(price1);
     //alert(price2);
     //alert(price3);
     //alert(price4);
     txtprice.innerHTML = '';
     var Cnts = drp.options[drp.selectedIndex].text;
     document.getElementById('ctl00_ContentPlaceHolder1_hdndrpvalue').value=Cnts;
     if (document.getElementById(drpv).selectedIndex == 0)
      {
        txtprice.innerHTML = '$0';
        txtaddprice.innerHTML = 0;
        document.getElementById('ctl00_ContentPlaceHolder1_hdndrpvalue').value=0;
        document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value=0;
        return false;
      }
     if (document.getElementById(drpobj).selectedIndex == 0) //Day
        {
           txtprice.innerHTML = '$'+ parseInt(Cnts)* parseInt(price1);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price1);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price1);
        }
     else if(document.getElementById(drpobj).selectedIndex == 1) //W
      {
           txtprice.innerHTML = '$'+ parseInt(Cnts)* parseInt(price2);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price2);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price2);
      }
     else if(document.getElementById(drpobj).selectedIndex == 2) //M
      {
           txtprice.innerHTML = '$'+ parseInt(Cnts)* parseInt(price3);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price3);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price3);
      }
     else if(document.getElementById(drpobj).selectedIndex == 3) //Y
      {
           txtprice.innerHTML ='$'+ parseInt(Cnts) * parseInt(price4);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price4);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price4);
      }
   }
   
   function setwebinarPrice1(drpobj,objprice,drpv,price1,price2,price3,price4,priceadd)
   {
     //alert(document.getElementById(drpobj).selectedIndex);
     //alert(objprice);
     var txtprice = document.getElementById(objprice);
     var txtaddprice = document.getElementById(priceadd);
     var drpbuyvalue = document.getElementById(drpv).selectedIndex
     var drp = document.getElementById(drpv);
     //alert(price1);
     //alert(price2);
     //alert(price3);
     //alert(price4);
     txtprice.innerHTML = '';
     var Cnts = drp.options[drp.selectedIndex].text;
     document.getElementById('ctl00_ContentPlaceHolder1_hdndrpvalue').value=Cnts;
     if (document.getElementById(drpv).selectedIndex == 0)
      {
        txtprice.innerHTML = 'Price: $0';
        txtaddprice.innerHTML = 0;
        document.getElementById('ctl00_ContentPlaceHolder1_hdndrpvalue').value=0;
        document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value=0;
        return false;
      }
     if (document.getElementById(drpobj).selectedIndex == 0) //Day
        {
           txtprice.innerHTML = 'Price: $'+ parseInt(Cnts)* parseInt(price1);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price1);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price1);
        }
     else if(document.getElementById(drpobj).selectedIndex == 1) //W
      {
           txtprice.innerHTML = 'Price: $'+ parseInt(Cnts)* parseInt(price2);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price2);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price2);
      }
     else if(document.getElementById(drpobj).selectedIndex == 2) //M
      {
           txtprice.innerHTML = 'Price: $'+ parseInt(Cnts)* parseInt(price3);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price3);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price3);
      }
     else if(document.getElementById(drpobj).selectedIndex == 3) //Y
      {
           txtprice.innerHTML = 'Price: $'+ parseInt(Cnts) * parseInt(price4);
           txtaddprice.innerHTML = parseInt(Cnts)* parseInt(price4);
           document.getElementById('ctl00_ContentPlaceHolder1_hdnprice').value= parseInt(Cnts)* parseInt(price4);
      }
   }
   
   
   function addcart(objcartprice)
   {
     //alert(document.getElementById(objcartprice));
     var cartprice = document.getElementById(objcartprice).innerHTML;
     //alert(cartprice);
     if (cartprice == 0)
     {
       alert("Please select any Buy Options for Webinar to add in cart...");
       return false;
     }
   }
   
  //Globla function for cart