﻿/// <reference name="MicrosoftAjax.debug.js" />
//Sys.Application.add_load(page_load);
//Sys.Application.add_unload(page_unload);

//Added by Firdose dated 14 april 2009
var cnt;
function showdiv() {
    if (cnt != 1) {


       // $('.note').show();
    }
}
function hidediv() {


    $('.note').hide();
}
function hidediv1() {

    //$('.notes').hide();
   // cnt = 1;
}
function showdiv1() {

    cnt = 0;


}
//ended
	 
function callTextChanged(ele) {
    var id = ele;
   // debugger;
    if (id = "txtName") {
        var txt = document.getElementById(id);
        //debugger;
                var txtvalue = "http://flipick.com/Username";
        txtvalue = txtvalue.replace("Username", "")
        txtvalue += txt.value;
        $get('lblUserName').innerHTML = txtvalue;
        //AjaxScript.CheckUserName(txt.value, callTextChangedSuccess);
        //debugger;
        //alert(txt.value.indexOf(" "));
        if (txt.value.indexOf(" ") > 0) {
            $get('DivUserNameInValid').style.display = "block";
            $get('DivUserNameValid').style.display = "none";
            document.getElementById("hdnNameErr").value = "1";

        }
        else if (txt.value.length < 4) {
            $get('DivUserNameInValid').style.display = "block";
            $get('DivUserNameValid').style.display = "none";
            document.getElementById("hdnNameErr").value = "1";
        }
        else if (checkNumeric(txt.value)) {
        $get('DivUserNameInValid').style.display = "block";
        $get('DivUserNameValid').style.display = "none";
        document.getElementById("hdnNameErr").value = "1";
          
        }
        else {

            AjaxScript.CheckUserName(txt.value, callTextChangedSuccess);
        }


    }
}

function callTextChangedSuccess(result) {
    if (result == false) {
        $get('DivUserNameInValid').style.display = "block";
        $get('DivUserNameValid').style.display = "none";
        document.getElementById("hdnNameErr").value = "1";
    }
    if (result == true) {

        document.getElementById("hdnNameErr").value = "0";
        $get('DivUserNameInValid').style.display = "none";
        $get('DivUserNameValid').style.display = "block";
    }
}

function callLoginTextChanged(ele) {
    var id = ele;
    if (id = "txtLoginName") {
        var txt = document.getElementById(id);
        var txtvalue = txt.value;
        AjaxScript.CheckUserName(txtvalue, callLoginTextChangedSuccess);
    }
}

function callLoginTextChangedSuccess(result) {
    if (result == true) {
        $get('DivLoginUserNameInValid').style.display = "block";
        $get('DivLoginUserNameValid').style.display = "none";
        document.getElementById("hdnLoginNameErr").value = "1";
    }
    if (result == false) {
        document.getElementById("hdnLoginNameErr").value = "0";
        $get('DivLoginUserNameInValid').style.display = "none";
        $get('DivLoginUserNameValid').style.display = "block";
        var strtxtLoginName = $get('txtLoginName').value;
    }
}

function page_unload() {

}

function callTextChangedPassword(elePassword) {
    debugger;
    var passwordText = elePassword;
    var strPassword = document.getElementById(elePassword).value;
    var minPasswordLen = document.getElementById('hdnPasswordLength').value;
    if (strPassword.length >= minPasswordLen) {
        document.getElementById("hdnPasswordErr").value = "0";
        $get('DivUserPasswordInValid').style.display = "none";
        $get('DivUserPasswordValid').style.display = "block";
    }
    else {
        document.getElementById("hdnPasswordErr").value = "1";
        $get('DivUserPasswordValid').style.display = "none";
        $get('DivUserPasswordInValid').style.display = "block";
    }
}


function callLoginTextChangedPassword(elePassword) {
    var passwordText = elePassword;
    var strPassword = document.getElementById(elePassword).value;
    var minPasswordLen = document.getElementById('hdnPasswordLength').value;
    var strUserName = $get('txtLoginName').value;
    AjaxScript.UserLogin(strUserName, strPassword, onSuccessAuthenticateUser);
}


function onSuccessAuthenticateUser(result) {
    if (result == "Success") {
        document.getElementById("hdnLoginPasswordErr").value = "0";
        $get('DivLoginPasswordInValid').style.display = "none";
        $get('DivLoginPasswordValid').style.display = "block";
    }
    else {
        document.getElementById("hdnLoginPasswordErr").value = "1";
        $get('DivLoginPasswordValid').style.display = "none";
        $get('DivLoginPasswordInValid').style.display = "block";
    }
}

function callTextChangedEmail(eleEmail) {
    //debugger;
    var EmailTxt = eleEmail;
    var strEmail = document.getElementById(eleEmail).value;
    if (echeck(strEmail)) {
        AjaxScript.CheckUserEmail(strEmail, onSuccessCheckUserEmail)
    }
    else {

        document.getElementById("hdnEmailErr").value = "1";
        $get('DivUserEmailInValid').style.display = "block";
        $get('DivUserEmailValid').style.display = "none";


    }
}


function onSuccessCheckUserEmail(result) {
    //debugger;
    if (result) {

        document.getElementById("hdnEmailErr").value = "1";
        $get('DivUserEmailInValid').style.display = "block";
        $get('DivUserEmailValid').style.display = "none";

    }
    else {

        document.getElementById("hdnEmailErr").value = "0";
        $get('DivUserEmailInValid').style.display = "none";
        $get('DivUserEmailValid').style.display = "block";

    }

}


function setMessage() {
   // debugger;
    ShowPopupMessage('tooltip_123');
    var errormsg = document.getElementById('lblMessage');
    errormsg.innerHTML = "The ladybug is sending over all of your account information to the email address you registered with.";
    

}

function SendMail() {
    var iName = $get('hdnNameErr').value;
    var iEmail = $get('hdnEmailErr').value;
    var iPass = $get('hdnPasswordErr').value;
    if (iName == 0 && iEmail == 0 && iPass == 0) {
        __doPostBack('LinkButton1', '');
    }
}

function callTextChangedEmailForgotPassword(eleForgotPass) {

    var strEmail = $get(eleForgotPass).value;
    //debugger;
    if (echeck(strEmail)) {


        document.getElementById("hdnEmailFPErr").value = "0";
        $get('FPEmailInValid').style.display = "none";
        $get('FPEmailValid').style.display = "block";
        AjaxScript.CheckUserEmail(strEmail, onSuccessChangedEmailForgotPassword);

    }
    else {
        document.getElementById("hdnEmailFPErr").value = "1";
        $get('FPEmailInValid').style.display = "block";
        $get('FPEmailValid').style.display = "none";

    }
}

function onSuccessChangedEmailForgotPassword(result) {
    // debugger;
    if (result == true) {
        document.getElementById("hdnEmailFPErr").value = "0";
        $get('FPEmailInValid').style.display = "none";
        $get('FPEmailValid').style.display = "block";
    }
    else {

        document.getElementById("hdnEmailFPErr").value = "1";
        $get('FPEmailInValid').style.display = "block";
        $get('FPEmailValid').style.display = "none";

    }


}

function CallSendUpdatedPassword() {

    //setMessage();


    var iEmail = $get('hdnEmailFPErr').value;
    if (iEmail == 0) {
        __doPostBack('lnkFP', '');
    }

}


function checkNumeric(value) {
    var anum = /(^\d+$)|(^\d+\.\d+$)/
    if (anum.test(value))
        return true;
    return false;
}


function validate() {
}

//                        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) {
//                                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;
//                        }
//                        

function echeck(strMail) {

//debugger;

    var regMail = /^\w+([-.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
    if (regMail.test(strMail)) {
        return true;
    }
    else {

        return false;

    }

}



 function js_waterMark_Focus(objname, waterMarkText, waterMarkStyle, normalStyle) {
//debugger;
    obj = document.getElementById(objname);
    if (obj.value == waterMarkText) {
        obj.value = "";
        obj.className = normalStyle
    }
}
function js_waterMark_Blur(objname, waterMarkText, waterMarkStyle, normalStyle) {

    obj = document.getElementById(objname);
    if (obj.value == "") {
        obj.value = waterMarkText;
        obj.className = waterMarkStyle
    }
    else {
        obj.className = normalStyle
    }
}

function js_waterMark_Focus_Password(objname, waterMarkText, waterMarkStyle, normalStyle) {
   // debugger; 
    obj = document.getElementById(objname);
    if (obj.value == waterMarkText) {
        obj.value = "";
        obj.className = normalStyle
        obj.type = 'password';
    }
}
function js_waterMark_Blur_Password(objname, waterMarkText, waterMarkStyle, normalStyle) {
   /// debugger; 
    obj = document.getElementById(objname);
    if (obj.value == "") {
        obj.value = waterMarkText;
        obj.className = waterMarkStyle
        obj.type = 'text';
    }
    else {
        obj.className = normalStyle
    }
}
function CallLogin() {
//    var iLoginNameErr = $get('hdnLoginNameErr').value;
//    var iLoginPasswordErr = $get('hdnLoginPasswordErr').value;
    //    if (iLoginNameErr == 0 && iLoginPasswordErr == 0) {
   //debugger;
    //alert("called");
        __doPostBack('lnkLogin', '');

    //}
}


 function LookArround_Click() {
            var valLogin;
            var valRegistrarion;
            var valLookarround;
            var valForgotPassword;
            reset();
            document.getElementById('HdnLoginDiv').value = "0";
            document.getElementById('HdnRegistrationDiv').value = "0";
            document.getElementById('HdnLookArroundDiv').value = "1";
            document.getElementById('hdnForgotPassword').value = "0";
            valLogin = document.getElementById('HdnLoginDiv').value;
            valRegistrarion = document.getElementById('HdnRegistrationDiv').value;
            valLookarround = document.getElementById('HdnLookArroundDiv').value;
            valForgotPassword = document.getElementById('hdnForgotPassword').value;
            SetAccess(valLogin, valRegistrarion, valLookarround, valForgotPassword);
        }        
        
        function LoginRegister_Click() {
            var valLogin;
            var valRegistrarion;
            var valLookarround;
            var valForgotPassword;
            reset();
            document.getElementById('HdnLoginDiv').value = "1";
            document.getElementById('HdnRegistrationDiv').value = "0";
            document.getElementById('HdnLookArroundDiv').value = "0";
            document.getElementById('hdnForgotPassword').value = "0";

            valLogin = document.getElementById('HdnLoginDiv').value;
            valRegistrarion = document.getElementById('HdnRegistrationDiv').value;
            valLookarround = document.getElementById('HdnLookArroundDiv').value;
            valForgotPassword = document.getElementById('hdnForgotPassword').value;
            SetAccess(valLogin, valRegistrarion, valLookarround, valForgotPassword);
        }
                
        function LoginClick() {
            var valLogin;
            var valRegistrarion;
            var valLookarround;
            var LoginLink;
            var valForgotPassword;
            reset();
            document.getElementById('HdnLoginDiv').value = "1";
            document.getElementById('HdnRegistrationDiv').value = "0";
            document.getElementById('HdnLookArroundDiv').value = "0";
            document.getElementById('hdnForgotPassword').value = "0";
            
            valLogin = document.getElementById('HdnLoginDiv').value;
            valRegistrarion = document.getElementById('HdnRegistrationDiv').value;
            valLookarround = document.getElementById('HdnLookArroundDiv').value;
            valForgotPassword = document.getElementById('hdnForgotPassword').value;
            SetAccess(valLogin, valRegistrarion, valLookarround, valForgotPassword);
        }
        
        function RegisterClick() {
            var valLogin;
            var valRegistrarion;
            var valLookarround;
            var LoginLink;
            reset();
            document.getElementById("login_flipick").style.display = "block";
            document.getElementById("lookarround").style.display = "none";
            document.getElementById("signup_flipick").style.display = "none";
            document.getElementById('spanLookArround').className = "interest";
            document.getElementById('spanLogin').className = "login_sel";
        }

        function ForgotPasswordClick() {
            reset();
            var ForgotDiv = $get('forgot_password');

            document.getElementById("signup_flipick").style.display = "none";
            document.getElementById("login_flipick").style.display = "none";
            document.getElementById("lookarround").style.display = "none";
            ForgotDiv.style.display = "block";
        }
        function SetAccess(valLogin, valRegistrarion, valLookarround, valForgotPassword) {
            $get('DivLoginPasswordValid').style.display = "none";
            $get('DivLoginPasswordInValid').style.display = "none";
            $get('DivUserPasswordInValid').style.display = "none";
            $get('DivUserPasswordValid').style.display = "none";
            $get('DivLoginUserNameInValid').style.display = "none";
            $get('DivLoginUserNameValid').style.display = "none";
            $get('DivUserNameInValid').style.display = "none";
            $get('DivUserNameValid').style.display = "none";
            if (valLogin == "1") {
                document.getElementById("signup_flipick").style.display = "block";
                document.getElementById('spanLookArround').className = "interest";
                document.getElementById('spanLogin').className = "login_sel";
                document.getElementById("login_flipick").style.display = "none";
                document.getElementById("lookarround").style.display = "none";
                document.getElementById("forgot_password").style.display = "none";
            }
            if (valRegistrarion == "1") {
                document.getElementById("login_flipick").style.display = "none";
                document.getElementById("lookarround").style.display = "none";
                document.getElementById("signup_flipick").style.display = "block";
                document.getElementById('spanLookArround').className = "interest";
                document.getElementById('spanLogin').className = "login_sel";
                document.getElementById("forgot_password").style.display = "none";
            }
            if (valLookarround == "1") {
                document.getElementById("lookarround").style.display = "block";
                document.getElementById("signup_flipick").style.display = "none";
                document.getElementById("login_flipick").style.display = "none";
                document.getElementById('spanLookArround').className = "interest_sel";
                document.getElementById('spanLogin').className = "login";
                document.getElementById("forgot_password").style.display = "none";
            }
            if (valForgotPassword == "1") {
                document.getElementById("signup_flipick").style.display = "none";
                document.getElementById('spanLookArround').className = "interest";
                document.getElementById('spanLogin').className = "login_sel";
                document.getElementById("login_flipick").style.display = "none";
                document.getElementById("lookarround").style.display = "none";
                document.getElementById("forgot_password").style.display = "block";
            }
        }


       


        function reset() {
            $get('hdnNameErr').value = 1;
            $get('hdnPasswordErr').value = 1;
            $get('hdnEmailErr').value = 1;
            $get('hdnEmailFPErr').value = 1;
            $get('hdnLoginNameErr').value = 1;
            $get('hdnLoginPasswordErr').value = 1;
            $get('DivUserEmailInValid').style.display = "none";       
            ///////////////////////////////////////////////////////////////////
            $get('txtLoginPassword').style.display = 'none';
            ///////////////////////////////////////////////////////////////////
            $get('mockpassLogin').style.display = 'block';
            $get('mockpassLogin').value = "Password";

            $get('txtPassword').style.display = 'none';
            $get('mockpass').style.display = 'block';
            $get('mockpass').value = "Password";
            
            
            $get('txtName').value = "Username";
            $get('txtPassword').value = "Password";
            $get('txtEmail').value = "Email";
            $get('txtLoginName').value = "Username";
            $get('txtLoginPassword').value = "";
            $get('ForgotPassYourEmail').value = "Email";

        }

        function attributeSet(elem, attrb, setting) {
            var elemAttrb = elem.getAttributeNode(attrb);
            if (elemAttrb) {
                elemAttrb.value = setting;
            } else {
                elem.setAttribute(attrb, setting);
            }
        }

        function randomClass() {
           //debugger;
            var classes = ["navy", "sand", "sandLite"];
            var index = Math.floor(Math.random() * classes.length);
            //attributeSet(document.getElementById('index'), 'class', classes[index]);
          //  $get('index').className = classes[index];
        }


        function page_load() {
          //  alert(HdnRegistrationDiv.Value);
    randomClass();
              var strClassName;
              //strClassName = $get('index').className;

             //debugger;

              strClassName = document.body.style.backgroundImage; 
              //debugger;
              if (strClassName == 'images/background-theme1.jpg') {

                  notes = [{ "x1": "10", "y1": "10", "height": "150", "width": "50", "note": "This is a note"}];
                  $('#index').imgNotes(); //If your notes data is is not named notes pass it  


              }

              if (strClassName == 'images/back2.gif') {

                  notes = [{ "x1": "10", "y1": "10", "height": "150", "width": "50", "note": "This is a note" }, { "x1": "55", "y1": "55", "height": "70", "width": "80", "note": "<b>This</b> is a new note This is another note This is a new note"}];
                  $('#index').imgNotes(); //If your notes data is is not named notes pass it  


              }

              if (strClassName == 'images/back3.gif') {

                  notes = [{ "x1": "25", "y1": "25", "height": "70", "width": "80", "note": "<b>This</b> is a new note This is another note This is a new note" }, { "x1": "35", "y1": "35", "height": "70", "width": "80", "note": "<b>This</b> is a new note This is another note This is a new note" }, { "x1": "45", "y1": "45", "height": "70", "width": "80", "note": "<b>This</b> is a new note This is another note This is a new note" }, { "x1": "55", "y1": "55", "height": "70", "width": "80", "note": "<b>This</b> is a new note This is another note This is a new note"}];

                  $('#index').imgNotes(); //If your notes data is is not named notes pass it  


              }
              
//              var flag=document.getElementById('hdnres').value; 
//              if(flag=="1")
//              {                            
//                document.getElementById('hdnres').value="0";
//                RegisterClick();                
//              }
          }


          function validateBugPopup() {

              var strReturn;
              var strFeedback = document.getElementById('txtDescription').value;
              //debugger;
              if (strFeedback != "" && strFeedback != "Your Message here") {
                  strReturn = true;
              }
              else {
                  strReturn = false;
                  document.getElementById('lblMessage').innerHTML = "Please enter message";
                  ShowPopupMessage('tooltip_123');
              }


              if (document.getElementById('hdnDetails').value == "1") {
                  var strName = document.getElementById('txtNameBug').value;
                  if (strName != "" && strName != "Name") {
                      strReturn = true;
                  }
                  else {
                      strReturn = false;
                      ShowPopupMessage('tooltip_123');
                      document.getElementById('lblMessage').innerHTML = "Please enter name";

                  }


                  var strEmail = document.getElementById('txtEmailBug').value;
                  if (strEmail != "" && strEmail != "Email") {
                      if (echeck(strEmail)) {
                          strReturn = true;
                      }
                      else {
                          strReturn = false;

                          ShowPopupMessage('tooltip_123');
                          document.getElementById('lblMessage').innerHTML = "Please enter valid email";
                      }

                  }
                  else {
                      strReturn = false;

                      ShowPopupMessage('tooltip_123');
                      document.getElementById('lblMessage').innerHTML = "Please enter email";
                  }

              }

              if (strReturn == true) {
                  //debugger;
                  __doPostBack('LinkButton110', '');
              }

          }



          function CallMe(ele) {
              // debugger;
              if (ele == 1) {
                  document.getElementById('video1').style.display = "block";
                  document.getElementById('video2').style.display = "none";
                  document.getElementById('lnkVideo1').className = "tab-sel";
                  document.getElementById('lnkVideo2').className = "";

              }
              if (ele == 2) {
                  document.getElementById('video1').style.display = "none";
                  document.getElementById('video2').style.display = "block";
                  document.getElementById('lnkVideo2').className = "tab-sel1";
                  document.getElementById('lnkVideo1').className = "";
              }

          }



          function MM_showHideLayers() { //v9.0
              var i, p, v, obj, args = MM_showHideLayers.arguments;
              if (v == 'show') {


              }

              if (v == 'hidden') {


              }
              for (i = 0; i < (args.length - 2); i += 3)
                  with (document) if (getElementById && ((obj = getElementById(args[i])) != null)) {
                  v = args[i + 2];
                  if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v == 'hide') ? 'hidden' : v; }
                  obj.visibility = v;
              }
          }





          function ShowDetails() {
              //alert('called');
              //debugger;    
              var strHdnDetails;
              strHdnDetails = document.getElementById('hdnDetails').value;

              if (strHdnDetails == "0") {
                  document.getElementById('DivDetails').style.display = "block";
                  document.getElementById('hdnDetails').value = "1";
              }
              else if (strHdnDetails == "1") {
                  document.getElementById('DivDetails').style.display = "none";
                  document.getElementById('hdnDetails').value = "0";
              }



          }
          
          
         

          //random images load function
          function Bodyonload() {


images = new Array(	// set up an array of the images
"images/casestudyimg1.jpg",
"images/casestudyimg2.jpg",
"images/casestudyimg3.jpg"
);

rand = Math.floor(Math.random()*images.length); // chose a random number, between 0 and the length of the array -1
currentImage = images[rand]; // set img to the random image's src
//$get('test2').className = classes[index];
//document.getElementById("test1").src = currentImage; // for img tag
document.body.style.backgroundImage = "url("+currentImage+")"; //for background	
document.body.style.backgroundRepeat = "no-repeat"; //for background


//document.body.style.background = "url("+img+")"; // set the background image
			switch (rand)
			  {
				  case 0:
				  {
                  notes = [{ "x1": "254", "y1": "195", "height": "56", "width": "56", "note": "I remember the exact day I bought these slippers, I was on spring break, saw them in a cornershop, tried them on, and fell so much in love that I bought two pairs. I definitely need a lifetime supply of these babies"}];
                  $('#mainWrapper').imgNotes();
                  //If your notes data is is not named notes pass it  
				  break;
             } 

              case 1: {
                  notes = [{ "x1": "359", "y1": "273", "height": "56", "width": "56", "note": "Pearl drums are the only drums that I am willing to use. This beat-up old kit lasted me through four years of wild college performances and is still going strong. The feel and attack of this set is just something I have never found in  another kit." }];
                  $('#mainWrapper').imgNotes();
                 
                    //If your notes data is is not named notes pass it  
				  break;
              }

              case 2: {
                  notes = [{ "x1": "439", "y1": "451", "height": "56", "width": "56", "note": "Every time I want to zone out and relax, all I need are these amazingly snug and comfy headphones. As soon as I flip on some tunes, I leave the rest of the world behind." }];
                  $('#mainWrapper').imgNotes();
                   //If your notes data is is not named notes pass it  
				  break;
			  }
			  }
      //        images = new array(	// set up an array of the images
//"images/casestudyimg1.jpg",
//"images/casestudyimg2.jpg",
//"images/casestudyimg3.jpg"
//);

//              rand = math.floor(math.random() * images.length); // chose a random number, between 0 and the length of the array -1
  //            currentimage = images[rand]; // set img to the random image's src

//              //document.getelementbyid("test1").src = currentimage; // for img tag
    //          document.getelementbyid("index").style.backgroundimage = "url(" + currentimage + ")"; //for div background	
      //        document.getelementbyid("index").style.backgroundrepeat = "no-repeat"; //for div background

  //            //document.body.style.background = "url("+img+")"; // set the background image


             var flag=document.getElementById('hdnres').value; 
              if(flag=="1")
              {                            
                
                document.getElementById('hdnres').value="0";
                RegisterClick();                
              }


	}


	function CallResend() {
	    //debugger;
	    __doPostBack('LinkButtonResend', '');
	}

	function CallCancel() {
	    //alert('Cancel');
	    document.getElementById('divRegPopup').style.display = "none";

	}

	function GetEnter(e) {
	    //debugger;
	    //alert(e.keyCode);
	    if (window.event) { e = window.event; }
	    if (e.keyCode == 13) {
	        // alert("called");
	        __doPostBack('LinkButtonResend', '');
	    }
	}



	function GetEnterSearch(e) {
	    debugger;
	    if (window.event) { e = window.event; }
	    if (e.keyCode == 13) {
	        //alert("called");
	        // __doPostBack('lnkLogin', '');

	        CallSearch();
	    }



	}
	

	


	
          
          
          