
var i=0;
//USED FOR AJAX
function getHTTPObject()
{
  var xmlhttp;
   /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try
    {
      xmlhttp = new XMLHttpRequest();
    }
    catch (e)
    {
      xmlhttp = false;
    }
  }
  return xmlhttp;

}


// search order with the criteria entered
function GeneralSearch( pType, e, websiteUrl )
{
    var key;

    // if IE
    if (window.event)
    {
        // catch the event
        e = window.event;
        key = e.keyCode;
    }
    else if(e.which)
    {
        // netscape
        key = e.which;
    }

    // if key pressed is enter key
    if ( key == '13' )
    {

		if(document.getElementById("txtSearch").value)
		{
		showSearchResults(websiteUrl);
        return false;
		}

    }
    else{
        return true;
    }

}

function sfunEnterKey( e ,div)
{
    var key;
    // if IE
    if (window.event)
    {
        // catch the event
        e = window.event;
        key = e.keyCode;
    }
    else if(e.which)
    {
        // netscape
        key = e.which;
    }
    // if key pressed is enter key
    if ( key == '13' )
    {
        var fdelement=div;
        evalstring="document.getElementById('"+fdelement+"')";
        var nextelement=eval(evalstring);
        nextelement.focus();
    }
}


/**
* This fuction is used to
*
* using ajax
*
* @access   public
* @param    null
*
* @return   null
*/
/*function getPageContent(divId,articleId,pageId){*/

    //alert(articleId);

  // var hidaction;

    //hidaction = "url-rewriting.html?action=getPageContent&articleId="+articleId+"&pageId="+pageId;
     /*featuredcontentglider.init({
    gliderid: "canadaprovinces", //ID of main glider container
    contentclass: "glidecontent", //Shared CSS class name of each glider content
    togglerid: "p-select", //ID of toggler container
    remotecontent: "url-rewriting.html?action=getPageContent&articleId="+articleId+"&pageId="+pageId+"", //Get gliding contents from external file on server? "filename" or "" to disable
    selected: 0, //Default selected content index (0=1st)
    persiststate: false, //Remember last content shown within browser session (true/false)?
    speed: 500, //Glide animation duration (in milliseconds)
    direction: "rightleft", //set direction of glide: "updown", "downup", "leftright", or "rightleft"
    autorotate: false, //Auto rotate contents (true/false)?
    autorotateconfig: [3000, 2] //if auto rotate enabled, set [milliseconds_btw_rotations, cycles_before_stopping]
});*/
   /* http = getHTTPObject(); // We create the HTTP Object


    //document.getElementById("loading").style.display="";


    http.open("GET", hidaction, true);
    http.onreadystatechange = function (){CSVHttpResponse1(divId)};
    http.send(null);*/
/*}*/

/**
* This fuction is used to
* handle ajax response
*
* @access   public
* @param    null
*
* @return   null
*/

/*function CSVHttpResponse1(divId){
    if (http.readyState == 4)
    {
        // only if "OK"
        if (http.status == 200)
        {

             var response  = http.responseText;



             //featuredcontentglider.init({remotecontent: 'response'});

              //document.getElementById('loader').style.display='none';
              //document.getElementById(divId).innerHTML = response;
             // document.forms[0].reset();


        }
    }
}*/


/**
* This fuction is used to validate the
* email
*
* @access   public
* @param    string
*
* @return   null
*/
function checkEmail(str) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
return (true)
}
alert("Invalid E-mail Address! Please Enter valid E-mail Address.");
return (false)
}

function changeExclusive(arrcount)
    {

        try {
        clearTimeout(to);
    } catch (e) {}



    to = setTimeout("nextExclusive("+arrcount+")", 5000);//2 sec
    }

    function nextExclusive(arrcount)
    {

        if(i<arrcount-1)
            i=i+1;
        else
            i=0;

        //alert(i);


        for(var j=0;j<arrcount;j++){
            if(j==i)
                document.getElementById("exclusiveSlide_"+i).style.display="";
            else
                document.getElementById("exclusiveSlide_"+j).style.display="none";

        }

        changeExclusive(arrcount);
    }


    function showExclusive(key,className,arrcount){//alert(key);


        for(var j=0;j<4;j++){
            if(j==key)
                document.getElementById("exclusiveSlide_"+key).style.display="";
            else
                document.getElementById("exclusiveSlide_"+j).style.display="none";

        }


            i=key;



    }


/**
* This fuction is used to save the
* user
*
* @access   public
* @param    string
*
* @return   null
*/

function downloadPDF(loginName,siteurl,articleId){
	//alert(articleId);
	if(loginName)
	{
		document.getElementById("action").value="downloadPDF";
		document.getElementById("hidArticleId").value=articleId;
		document.getElementById("frmDevMarch").submit();
	}
	else
	{
		//document.location.href=siteurl+"/login.html";
		alert('You have to login to download this document.');
		document.getElementById("action").value="goToLogin";
		document.getElementById("frmDevMarch").submit();
	}
}

/**
* This fuction is used to save the
* user
*
* @access   public
* @param    string
*
* @return   null
*/

function registerUser(){

    if(validateUser())
    {
		if(validateCaptcha())
		{
           document.getElementById("action").value="RegisterUser";
           document.getElementById("frmDevMarch").submit();
		}
    }
}

/**
* This fuction is used to validate User details
*
* @access   public
* @param    null
*
* @return   boolean
*/

function validateUser()
{
    if(document.getElementById("firstname").value.match(/^ *$/))

    {
        alert("Please enter first name.");
        document.getElementById("firstname").focus();
        return;
    }

	else if(document.getElementById("lastname").value.match(/^ *$/))

    {
        alert("Please enter last name.");
        document.getElementById("lastname").focus();
        return;
	}
	else if(document.getElementById("company").value.match(/^ *$/))

    {
        alert("Please enter your company.");
        document.getElementById("company").focus();
        return;
	}
	else if(document.getElementById("jobTitle").value.match(/^ *$/))

    {
        alert("Please enter your job title.");
        document.getElementById("jobTitle").focus();
        return;
	}
	else if(document.getElementById("phone").value.match(/^ *$/))

    {
        alert("Please enter your phone number.");
        document.getElementById("phone").focus();
        return;
	}
	 else if(checkEmail(document.getElementById("emailId").value)!=true)
    {
        //alert("Please Enter valid Email.!!!!");
        document.getElementById("emailId").value='';
        document.getElementById("emailId").focus();
        return;
    }

    else if(document.getElementById("loginId").value.match(/^ *$/))

    {
        alert("Please enter user name.");
        document.getElementById("loginId").focus();
        return;
    }

    else if(document.getElementById("passwd").value.match(/^ *$/))

    {
        alert("Please enter password.");
        document.getElementById("passwd").focus();
        return;
    }

    else if(document.getElementById("passwd").value != document.getElementById("repasswd").value )

    {
        alert("Password mismatch.");
        return;
    }
	 /*else if(document.getElementById("conference").checked!='true')
    {
        alert("Please select your area of interest");
        document.getElementById("conference").focus();
        return;
    }*/
    return true;
}


function saveAdvertise(){

    if(validateAdvertise())
    {
		if(validateCaptcha())
		{
           document.getElementById("action").value="SaveAdvertise";
           document.getElementById("frmDevMarch").submit();
		}
    }
}

function validateAdvertise()
{
    if(document.getElementById("firstname").value.match(/^ *$/))

    {
        alert("Please enter first name.");
        document.getElementById("firstname").focus();
        return;
	}
	else if(document.getElementById("lastname").value.match(/^ *$/))

    {
        alert("Please enter last name.");
        document.getElementById("lastname").focus();
        return;
	}
	else if(document.getElementById("company").value.match(/^ *$/))

    {
        alert("Please enter your company.");
        document.getElementById("company").focus();
        return;
	}
	else if(checkEmail(document.getElementById("emailId").value)!=true)
    {
        //alert("Please Enter valid Email.!!!!");
        document.getElementById("emailId").value='';
        document.getElementById("emailId").focus();
        return;
    }
	if(document.getElementById("regarding").value=='new')

    {
        alert("Please select the title.");
        document.getElementById("regarding").focus();
        return;
    }
	else if(document.getElementById("message").value.match(/^ *$/))

    {
        alert("Please enter your message.");
        document.getElementById("message").focus();
        return;
	}

    return true;
}

function saveContactUs()
{
    if(validateContactUs())
    {
		if(validateCaptcha())
		{
           document.getElementById("action").value="SaveContactUs";
           document.getElementById("frmDevMarch").submit();
		}
    }
}


function validateContactUs()
{
    if(document.getElementById("moreInformation").value=='new')

    {
        alert("Please select more information title.");
        document.getElementById("moreInformation").focus();
        return;
    }

	else if(document.getElementById("firstname").value.match(/^ *$/))

    {
        alert("Please enter first name.");
        document.getElementById("firstname").focus();
        return;
	}
	else if(document.getElementById("lastname").value.match(/^ *$/))

    {
        alert("Please enter last name.");
        document.getElementById("lastname").focus();
        return;
	}
	else if(document.getElementById("company").value.match(/^ *$/))

    {
        alert("Please enter your company.");
        document.getElementById("company").focus();
        return;
	}
	else if(document.getElementById("designation").value.match(/^ *$/))

    {
        alert("Please enter your designation.");
        document.getElementById("designation").focus();
        return;
	}
	 else if(checkEmail(document.getElementById("emailId").value)!=true)
    {
        //alert("Please Enter valid Email.!!!!");
        document.getElementById("emailId").value='';
        document.getElementById("emailId").focus();
        return;
    }
	else if(document.getElementById("telephone").value.match(/^ *$/))

    {
        alert("Please enter your phone number.");
        document.getElementById("telephone").focus();
        return;
	}
    else if(document.getElementById("comments").value.match(/^ *$/))

    {
        alert("Please enter your comments.");
        document.getElementById("comments").focus();
        return;
    }
    return true;
}

function validateCaptcha()
{
    challengeField = $("input#recaptcha_challenge_field").val();
    responseField = $("input#recaptcha_response_field").val();
    //alert(challengeField);
    //alert(responseField);
    //return false;
    var html = $.ajax({
    type: "POST",
    url: "./inc/reCAPTCHA/ajax.recaptcha.php",
    data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
    async: false
    }).responseText;

    if(html == "success")
    {
		document.getElementById('captchaStatus').style.display="";
        $("#captchaStatus").html("Success. Submitting form.");
        //return false;
        // Uncomment the following line in your application
        return true;
    }
    else
    {
		document.getElementById('captchaStatus').style.display="";
        $("#captchaStatus").html("Your captcha is incorrect. Please try again");
        Recaptcha.reload();
        return false;
    }
}

/**
* This fuction is used to check the
* forgot password
*
* @access   public
* @param    string
*
* @return   null
*/

function forgotPassword()
{
    if(document.getElementById("uname").value.match(/^ *$/))
    {
		document.getElementById("uname").value='';
        document.getElementById("uname").focus();
        return;
    }
	  document.getElementById("action").value="ForgotPassword";
      document.getElementById("frmDevMarch").submit();
}

/**
* This fuction is used to check the
* forgot password
*
* @access   public
* @param    string
*
* @return   null
*/

function forgotUsername(){

    if(checkEmail(document.getElementById("emailId").value)!=true)
    {

		document.getElementById("emailId").value='';
        document.getElementById("emailId").focus();
        return;

    }
	  document.getElementById("action").value="ForgotPassword";
      document.getElementById("frmDevMarch").submit();
}

/**
* This fuction is used to check the
* forgot password
*
* @access   public
* @param    string
*
* @return   null
*/

function changePassword(){

    if(document.getElementById("passwd").value.match(/^ *$/))

    {
        alert("Please enter password.");
        document.getElementById("passwd").focus();
        return;
    }

    else if(document.getElementById("passwd").value != document.getElementById("repasswd").value )

    {
        alert("Password mismatch.");

        return;
    }
	  document.getElementById("action").value="ChangePassword";
      document.getElementById("frmDevMarch").submit();
}







/**
* This function is used to
* submit login page
*
* @access   public
* @param    null.
*
* @return   null.
*/

function loginUser()
{

    if(document.getElementById("username").value.match(/^ *$/))

    {
        alert("Please enter the user name.");
        document.getElementById("username").focus();
        return;
    }

    else if(document.getElementById("password").value.match(/^ *$/))

    {
        alert("Please enter the password.");
        document.getElementById("password").focus();
        return;
    }
    document.getElementById("action").value="LoginUser";
    document.getElementById("frmDevMarch").submit();
}

/**
* This function is used to
* get article div height
*
* @access   public
* @param    null.
*
* @return   null.
*/


function getArtcleDivHeight(pageNo){

	//alert(pageNo);


    var divheight1;
    var divheight =new Array();

    //alert(document.getElementById("testart7").offsetHeight);
    for( var i=1;i<pageNo;i++){
        //var articleDiv =;
        //alert(pageNo);
        var articleDiv='articleDiv'+i;
        //alert(document.getElementById(articleDiv));

         divheight[i]=document.getElementById(articleDiv).offsetHeight;

		 if(pageNo==2){
			 divheight1=divheight[i];
		 }
        else if(divheight[i]>divheight[i-1]){
             divheight1=divheight[i];
        }
        else{
             divheight1=divheight[i-1];
        }
    }
    //alert(divheight1);
    document.getElementById("canadaprovinces").style.height=divheight1;
    //document.getElementById("canadaprovinces").style.height=divheight1;


}

/**
* This fuction is used log banner clicks
*
*
* @access   public
* @param    string
*
* @return   null
*/

function LogBannerClicks(bannerId){
	document.getElementById("hidBannerId").value=document.getElementById(bannerId).value;
	document.getElementById("action").value="logBannerClicks";
	document.getElementById("frmDevMarch").submit();
}

/**
* This fuction is used to
* show all search  results
*
* @access   public
* @param    null
*
* @return   null
*/
function showSearchResults(websiteUrl)
{
	searchTxt=document.getElementById("txtSearch").value;
	document.frmDevMarch.action = websiteUrl+"/search-results.html?q="+searchTxt+"&p=1";
	document.getElementById("action").value="showSearchResults";
    location.replace("search-results.html?q="+searchTxt+"&p=1");
	document.getElementById("frmDevMarch").submit();

	/*if(document.getElementById("txtSearch").value!='')
	{
        document.frmDevMarch.action =websiteUrl+ "/search-results.html";
        document.getElementById("action").value="showSearchResults";
        document.getElementById("frmDevMarch").submit();
	}*/
}








