﻿//MAIN Javascript Function For RAKHI ======03-AUG-2010======
//AjaxLogin Function Starts//
var strDomain = 'http://www.giftstoindia24x7.com/';
//var strDomain = 'http://localhost:1282/';
function IsNumeric(e){var KeyID=(window.event)?event.keyCode:e.which;if((KeyID>=66&&KeyID<=90)||(KeyID>=97&&KeyID<=122)||(KeyID>=33&&KeyID<=47)||(KeyID>=58&&KeyID<=64)||(KeyID>=91&&KeyID<=96)||(KeyID>=123&&KeyID<=126)){return false;}return true;}
function allowedKey(e){var KeyID=(window.event)?event.keyCode:e.which;if((KeyID>=33&&KeyID<=47)||(KeyID==32)||(KeyID>=58&&KeyID<=64)||(KeyID>=91&&KeyID<=94)||(KeyID==96)||(KeyID>=123&&KeyID<=126)){return false;}return true;}
var s=0;var interv;function userLogin(obj)
{var oui=document.getElementById("Uc_Header_New_Rakhi1_uid");var oup=document.getElementById("Uc_Header_New_Rakhi1_pwd");var om=document.getElementById("Uc_Header_New_Rakhi1_login1");var ajx=document.getElementById("ajxLoad");var lggd=document.getElementById("Uc_Header_New_Rakhi1_loggedin");if(oui!=null&&oup!=null&&om!=null&&lggd!=null&&ajx!=null)
{if(oui.value==""||oup.value=="")
{alert("Please mention user Id and Password both, then try again.");if(oui.value==null||oui.value==""){oui.focus();}else{oup.focus();}}
else
{if(validateEmail(oui.value))
{var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
{self.xmlHttpReq=new XMLHttpRequest();}
else if(window.ActiveXObject)
{self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}
self.xmlHttpReq.open('POST',strDomain + "ajaxLogin.aspx",true);self.xmlHttpReq.setRequestHeader('Content-Type','application/x-www-form-urlencoded');self.xmlHttpReq.onreadystatechange=function()
{if(self.xmlHttpReq.readyState==4)
{om.disabled=false;ajx.style.display="none";var GetValue=new Array();if(self.xmlHttpReq.responseText.indexOf('~'!=-1))
{GetValue=self.xmlHttpReq.responseText.split("~");if(GetValue[0]=="0")
{om.style.display="block";alert(GetValue[1].toString());oup.value="";oup.focus();}
else if(GetValue[0]=="1")
{om.style.display="none";lggd.style.display="block";lggd.innerHTML=GetValue[1].toString();oui.value="";oup.value="";}}
else
{om.disabled=false;alert("Due to some error you are not allowed to log in. Please try later.");}}
else
{om.disabled=true;ajx.style.display="block";}}
self.xmlHttpReq.send("Mode=userLogin&userId="+encodeURIComponent(oui.value)+"&userPwd="+encodeURIComponent(oup.value));}
else
{alert("Please mention a valid email address. Then try again!");oui.focus();}}}
else
{alert("Due to some error you are not allowed to log in. Please refresh the page and try again.");}}
function red(){s++;if(s==5){clearInterval(interv);window.location.href="http://www.giftstoindia24x7.com";}}
function clearForm(uId,pwd)
{var oui=document.getElementById('uid');var oup=document.getElementById('pwd');if(oui!=null&&oup!=null)
{oui.value="";oup.value="";oui.focus();}
else
{alert("Error retrieving the objects. Please try later.");}}
function validateEmail(str)
{if(str)
{var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if(str.indexOf(at)==-1)
{return false;}
if(str.indexOf(at)==-1||str.indexOf(at)==0||str.indexOf(at)==lstr)
{return false;}
if(str.indexOf(dot)==-1||str.indexOf(dot)==0||str.indexOf(dot)==lstr)
{return false;}
if(str.indexOf(at,(lat+1))!=-1)
{return false;}
if(str.substring(lat-1,lat)==dot||str.substring(lat+1,lat+2)==dot)
{return false;}
if(str.indexOf(dot,(lat+2))==-1)
{return false;}
if(str.indexOf(" ")!=-1)
{return false;}
return true}
else
{return false;}}
function logout(obj)
{var oa=document.getElementById('ajxLoad');var ol=document.getElementById('Uc_Header_New_Rakhi1_login1');var olo=document.getElementById('Uc_Header_New_Rakhi1_loggedin');if(oa!=null&&ol!=null&&olo!=null)
{var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
{self.xmlHttpReq=new XMLHttpRequest();}
else if(window.ActiveXObject)
{self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}
self.xmlHttpReq.open('POST', strDomain + "ajaxLogin.aspx", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function()
{if(self.xmlHttpReq.readyState==4)
{oa.style.display="none";if(self.xmlHttpReq.responseText.toString()!="")
{if(self.xmlHttpReq.responseText.indexOf('~'!=-1))
{GetValue=self.xmlHttpReq.responseText.split("~");if(GetValue[0]=="0")
{ol.style.display="none";olo.style.display="block";}
else if(GetValue[0]=="1")
{ol.style.display="block";olo.style.display="none";window.location.href="http://www.giftstoindia24x7.com/";}}
else
{alert("Sorry, we cannot you let you logout this time. Please try later.");}}
else
{alert("Sorry, we cannot you let you logout this time. Please try later.");}}
else
{ol.style.display="none";olo.style.display="none";oa.style.display="block";}}
self.xmlHttpReq.send("Mode=userLogout");}}
function checklogin(obj)
{alert(parent.document.getElementById("Uc_Header_New_Rakhi1_login1").innerHTML);}
function ForgotPasswordMail(obj)
{var objemail=document.getElementById("Uc_Header_New_Rakhi1_txtId");var lblerror=document.getElementById("Uc_Header_New_Rakhi1_lblError");if(objemail!=null)
{var email=objemail.value;if(validateEmail(email))
{var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
{self.xmlHttpReq=new XMLHttpRequest();}
else if(window.ActiveXObject)
{self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}
self.xmlHttpReq.open('POST', strDomain + "ajaxLogin.aspx", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function()
{if(self.xmlHttpReq.readyState==4)
{if(self.xmlHttpReq.responseText.toString()!="")
{if(self.xmlHttpReq.responseText.indexOf('~'!=-1))
{GetValue=self.xmlHttpReq.responseText.split("~");if(GetValue[0]=="forgotmail")
{if(GetValue[1]=="T")
{lblerror.innerHTML="Mail has been sent. Please check inbox or the bulk mail folder.";}
else
{lblerror.innerHTML="Email not found in database.Please re-type email.";}}}}}}
self.xmlHttpReq.send("Mode=forgotmail&email="+email+"");}
else
{lblerror.innerHTML="Please provide valid email address."}}
else
{lblerror.innerHTML="Please provide valid email address."}}
function ForgotPasswordMail1(obj)
{var objemail=document.getElementById("txtId1");var lblerror=document.getElementById("lblError1");if(objemail!=null)
{var email=objemail.value;if(validateEmail(email))
{var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
{self.xmlHttpReq=new XMLHttpRequest();}
else if(window.ActiveXObject)
{self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}
self.xmlHttpReq.open('POST', strDomain + "ajaxLogin.aspx", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function()
{if(self.xmlHttpReq.readyState==4)
{if(self.xmlHttpReq.responseText.toString()!="")
{if(self.xmlHttpReq.responseText.indexOf('~'!=-1))
{GetValue=self.xmlHttpReq.responseText.split("~");if(GetValue[0]=="forgotmail")
{if(GetValue[1]=="T")
{lblerror.innerHTML="Mail has been sent. Please check inbox or the bulk mail folder.";}
else
{lblerror.innerHTML="Email not found in database.Please re-type email.";}}}}}}
self.xmlHttpReq.send("Mode=forgotmail&email="+email+"");}
else
{lblerror.innerHTML="Please provide valid email address."}}
else
{lblerror.innerHTML="Please provide valid email address."}}
//AjaxLogin Function Ends//
//Price Change RAKHI Function STARTS//
function sndUserCheckforcolor(theOpt)
{ http.open("get", strDomain + "Ajax.aspx?proid=" + theOpt.value + "&ajmode=color"); http.onreadystatechange = handleResponse; http.send(null); }
function sndUserCheckforsize(theOpt)
{ http.open("get", strDomain + "Ajax.aspx?proid=" + theOpt.value + "&ajmode=size"); http.onreadystatechange = handleResponse; http.send(null); }
function SelectedItem(theOpt,theTxt)
{ window.location.href = strDomain + "category.aspx?cat=" + theOpt.value + "&searchterm=" + theTxt.value; }
function SetDivIndexPrice(theDiv,theOpt,theFlag)
{if(theDiv!=null&&theOpt!=null)
{var i;var CurrencyUnit=new Array();var collDivs=document.getElementsByTagName('DIV');if(collDivs!=null)
{theFlag.innerHTML="<img src='http://img2.giftstoindia24x7.com/Pictures/"+theOpt.options[theOpt.selectedIndex].text+".jpg' width='29' height='15'>";for(i=0;i<collDivs.length;i++)
{if(theDiv.id==collDivs[i].id)
{CurrencyUnit=theOpt.value.split(",");alert(CurrencyUnit[2]);collDivs[i].innerHTML="Rs. "+collDivs[i].title+" / "+CurrencyUnit[1]+" "+(collDivs[i].title/CurrencyUnit[2]).toFixed(2);}}}}
else
{alert("No price found to change.");}}
function setDivPrice(theDiv,theOpt,theFlag)
{var bFlag=false;if(theOpt!=null)
{var xmlHttpReq=false;var self=this;if(window.XMLHttpRequest)
{self.xmlHttpReq=new XMLHttpRequest();}
else if(window.ActiveXObject)
{self.xmlHttpReq=new ActiveXObject("Microsoft.XMLHTTP");}
self.xmlHttpReq.open('POST', strDomain + "ajaxCommonFunction_ppnl.aspx", true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); self.xmlHttpReq.onreadystatechange = function()
{if(self.xmlHttpReq.readyState==4)
{theOpt.disabled=false;var GetValue=new Array();if(self.xmlHttpReq.responseText.indexOf('~'!=-1))
{GetValue=self.xmlHttpReq.responseText.split("~");}
if(GetValue[0].toString()!="")
{if(GetValue[0].toString()=="0")
{alert("Error : "+GetValue[1].toString());}
else
{var collDivs=document.getElementsByTagName('SPAN');if(collDivs!=null)
{theFlag.innerHTML="<img src=\"http://img2.giftstoindia24x7.com/Pictures/"+theOpt.options[theOpt.selectedIndex].text+".jpg\" width=\"29\" height=\"15\">";for(var i=0;i<collDivs.length;i++)
{var att=collDivs[i].getAttribute("name");if(att=="ProductPrice")
{bFlag=true;collDivs[i].innerHTML="Rs. "+collDivs[i].title+" / "+GetValue[1].toString()+" "+(collDivs[i].title/GetValue[2]).toFixed(2);}}}
if(bFlag==false)
{var collDivs=document.getElementsByTagName('DIV');theDiv=document.getElementById('ProductPrice');if(collDivs!=null)
{theFlag.innerHTML="<img src=\"http://img2.giftstoindia24x7.com/Pictures/"+theOpt.options[theOpt.selectedIndex].text+".jpg\" width=\"29\" height=\"15\">";for(i=0;i<collDivs.length;i++)
{if(theDiv.id==collDivs[i].id)
{collDivs[i].innerHTML="Rs. "+collDivs[i].title+" / "+GetValue[1].toString()+" "+(collDivs[i].title/GetValue[2]).toFixed(2);}}}}
else
{var collDivs=document.getElementsByTagName('DIV');theDiv=document.getElementById('ProductPrice');if(theDiv!=null)
{theFlag.innerHTML="<img src=\"http://img2.giftstoindia24x7.com/Pictures/"+theOpt.options[theOpt.selectedIndex].text+".jpg\" width=\"29\" height=\"15\">";for(i=0;i<collDivs.length;i++)
{if(theDiv.id==collDivs[i].id)
{collDivs[i].innerHTML="Rs. "+collDivs[i].title+" / "+GetValue[1].toString()+" "+(collDivs[i].title/GetValue[2]).toFixed(2);}}}}}}
else
{alert("Sorry! Due to some error currency cannot be changed.");}}
else
{theOpt.disabled=true;theFlag.innerHTML="<img src=\"Pictures/loading.gif\" width=\"20\" height=\"20\">";}}
self.xmlHttpReq.send("mode=1&currId="+theOpt.value);}
else
{alert("Sorry! No price found to change. Cannot Change currency.");}}
//Price Change RAKHI Function ENDS//
//SelectBox Function Starts//
var Globals={initialize:function(){Custom.init();Convert.init();Fade.initialize();}}
window.onload=Globals.initialize;var checkboxHeight="25";var radioHeight="25";var selectWidth="139";document.write('<style type="text/css">input.styled { display: none; } select.styled { position: relative; width: '+selectWidth+'px; opacity: 0; filter: alpha(opacity=0); z-index: 5; }</style>');var Custom={init:function(){var inputs=document.getElementsByTagName("input"),span=Array(),textnode,option,active;for(a=0;a<inputs.length;a++){if((inputs[a].type=="checkbox"||inputs[a].type=="radio")&&inputs[a].className=="styled"){span[a]=document.createElement("span");span[a].className=inputs[a].type;if(inputs[a].checked==true){if(inputs[a].type=="checkbox"){position="0 -"+(checkboxHeight*2)+"px";span[a].style.backgroundPosition=position;}else{position="0 -"+(radioHeight*2)+"px";span[a].style.backgroundPosition=position;}}
inputs[a].parentNode.insertBefore(span[a],inputs[a]);inputs[a].onchange=Custom.clear;span[a].onmousedown=Custom.pushed;span[a].onmouseup=Custom.check;document.onmouseup=Custom.clear;}}
inputs=document.getElementsByTagName("select");for(a=0;a<inputs.length;a++){if(inputs[a].className=="styled"){option=inputs[a].getElementsByTagName("option");active=option[0].childNodes[0].nodeValue;textnode=document.createTextNode(active);for(b=0;b<option.length;b++){if(option[b].selected==true){textnode=document.createTextNode(option[b].childNodes[0].nodeValue);}}
span[a]=document.createElement("span");span[a].className="select";span[a].id="select"+inputs[a].name;span[a].appendChild(textnode);inputs[a].parentNode.insertBefore(span[a],inputs[a]);inputs[a].onchange=Custom.choose;}}},pushed:function(){element=this.nextSibling;if(element.checked==true&&element.type=="checkbox"){this.style.backgroundPosition="0 -"+checkboxHeight*3+"px";}else if(element.checked==true&&element.type=="radio"){this.style.backgroundPosition="0 -"+radioHeight*3+"px";}else if(element.checked!=true&&element.type=="checkbox"){this.style.backgroundPosition="0 -"+checkboxHeight+"px";}else{this.style.backgroundPosition="0 -"+radioHeight+"px";}},check:function(){element=this.nextSibling;if(element.checked==true&&element.type=="checkbox"){this.style.backgroundPosition="0 0";element.checked=false;}else{if(element.type=="checkbox"){this.style.backgroundPosition="0 -"+checkboxHeight*2+"px";}else{this.style.backgroundPosition="0 -"+radioHeight*2+"px";group=this.nextSibling.name;inputs=document.getElementsByTagName("input");for(a=0;a<inputs.length;a++){if(inputs[a].name==group&&inputs[a]!=this.nextSibling){inputs[a].previousSibling.style.backgroundPosition="0 0";}}}
element.checked=true;}},clear:function(){inputs=document.getElementsByTagName("input");for(var b=0;b<inputs.length;b++){if(inputs[b].type=="checkbox"&&inputs[b].checked==true&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 -"+checkboxHeight*2+"px";}else if(inputs[b].type=="checkbox"&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 0";}else if(inputs[b].type=="radio"&&inputs[b].checked==true&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 -"+radioHeight*2+"px";}else if(inputs[b].type=="radio"&&inputs[b].className=="styled"){inputs[b].previousSibling.style.backgroundPosition="0 0";}}},choose:function(){option=this.getElementsByTagName("option");for(d=0;d<option.length;d++){if(option[d].selected==true){document.getElementById("select"+this.name).childNodes[0].nodeValue=option[d].childNodes[0].nodeValue;}}}}
var Convert={init:function(){var spans=document.getElementsByTagName("span");for(var i=0;i<spans.length;i++){if(spans[i].className=="address"){string=spans[i].childNodes[0].nodeValue;email=string.split("_")[0]+"@"+string.split("_")[2];spans[i].innerHTML='<a href="mailto:'+email+'">'+email+'</a>';}}}}
var stage=new Array(),img,rotate=0,opac=100,int;var Fade={initialize:function(){if(document.getElementById("stage")){img=document.getElementById("stage");stage[0]=new Image();stage[0].src="/workspace/images/stage-one.png";stage[1]=new Image();stage[1].src="/workspace/images/stage-two.png";stage[2]=new Image();stage[2].src="/workspace/images/stage-three.png";setTimeout("Fade.fadeOut()",3000);}},fadeOut:function(){opac=(opac-10);img.style.opacity=(opac/100);img.style.filter="alpha(opacity="+opac+")";if(opac==90){int=setInterval("Fade.fadeOut()",50);}else if(opac==0){clearInterval(int);Fade.switchImage(img);}},fadeIn:function(){opac=(opac+20);img.style.opacity=(opac/100);img.style.filter="alpha(opacity="+opac+")";if(opac==20){int=setInterval("Fade.fadeIn()",50);}else if(opac==100){clearInterval(int);setTimeout("Fade.fadeOut()",5000);}},switchImage:function(){rotate++;if(rotate==stage.length){rotate=0;}
img.src=stage[rotate].src;Fade.fadeIn();}}
//SelectBox Function Ends//
//drop Function Starts//
function dropmenu(active,show){document.getElementById(active).className="active";document.getElementById(show).style.visibility="visible";}
function hidemenu(active,show){document.getElementById(active).className="";document.getElementById(show).style.visibility="hidden";}
function dropmenu1(show){document.getElementById(show).style.visibility="visible";}
function hidemenu1(show){document.getElementById(show).style.visibility="hidden";}
//drop Function Ends//
