﻿// JScript File
var strButtonClicked = ""


function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '');
}

function validateEmail(strEmail) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   
   if(reg.test(strEmail) == false) {
      
      return false;
   }
   return true;
}

var arrAdsImage=new Array();
var arrAdsHref=new Array();
var iAdsCurIndex = 0;

function MoveAds(iMode)
{
    if (iMode==0)
    {
        if (iAdsCurIndex==0)
            iAdsCurIndex=arrAdsImage.length-1
        else
            iAdsCurIndex--;
    }else
    {
        if (iAdsCurIndex==arrAdsImage.length-1)
            iAdsCurIndex=0
        else
            iAdsCurIndex++
    }
    $('lnkAds').href= arrAdsHref[iAdsCurIndex]
    $('imgAds').src= arrAdsImage[iAdsCurIndex]
}


function AutoSlideAds()
{
    MoveAds(1)
    setTimeout("AutoSlideAds()",6000)
}


function checkNumeric(event)
{
   var keyCode
   if (event.which != null)
        keyCode = event.which
   else
        keyCode = event.keyCode


    if (!((keyCode >=48 && keyCode <=57) || keyCode == 8 || keyCode ==0))
            return false;

}


function fncSearchStore(url)
{
    /*if ($("ctl00_webCtlSearch_ddlCategories").value != '')
        url = url + "?srcCatID=" + $("ctl00_webCtlSearch_ddlCategories").value 
    if ($("ctl00_webCtlSearch_ddlSubCategories").value != '')
        url = url + "&srcSubCatID=" + $("ctl00_webCtlSearch_ddlSubCategories").value 
*/
    if (strButtonClicked == "")
    {
        strButtonClicked = "store";
        document.forms[0].action=url;
        //document.forms[0].method = "get"
    }
}

function fncSearch()
{


    
    strButtonClicked = ""
    return true;
}

function txtSearch_onFocus(strInit)
{
    if ($("ctl00_txtSearch").value == strInit)
    {
        $("ctl00_txtSearch").value = "";
    }
}

function txtSearchShop_onBlur(strInit)
{
    if ($("ctl00_webCtlSearch_txtShopSrch").value == "")
    {
        $("ctl00_webCtlSearch_txtShopSrch").value = strInit;
    }
}


function txtSearchShop_onFocus(strInit)
{
    if ($("ctl00_webCtlSearch_txtShopSrch").value == strInit)
    {
        $("ctl00_webCtlSearch_txtShopSrch").value = "";
    }
}

function txtSearch_onBlur(strInit)
{
    if ($("ctl00_txtSearch").value == "")
    {
        $("ctl00_txtSearch").value = strInit;
    }
}

function window_onload()
{
    if (window.opener != null)
    {
        //window.opener.document.forms[0].target = "";
    }
    
    document.forms[0].target=''
    
    if (arrAdsHref[0] != null)
    {
        setTimeout("AutoSlideAds()",6000);
    }   
}

function dspIconsTxt(str,intShow,index) // displays text next to icons
{
   if(intShow){
        $('control'+index).innerHTML="<span>"+str+"</span>";
   }
   else{
        $('control'+index).innerHTML="";
   }
}

function dspShopIconsTxt(str,intShow) // displays text next to icons
{
   if(intShow){
        $('controlShopText').innerHTML="<span>"+str+"<br />&nbsp;</span>";
   }
   else{
        $('controlShopText').innerHTML="&nbsp;";
   }
}



function txtCompetition_Keydown(event)
{
    if (event.keyCode == 13) {
        $("ctl00_holderContent_btnSubmitCompetition").focus();
    }

}


function ddlCountry_Change()
{
    if ($('ctl00_holderContent_ddlCountry').value == "Australia")
    {
        $('ctl00_holderContent_cTxtPostCode').value = ""
        $('thPostcode').style.display = "inline"
        $('tdPostcode').style.display = "inline"
    }else
    {
        $('thPostcode').style.display = "none"
        $('tdPostcode').style.display = "none"
        $('ctl00_holderContent_cTxtPostCode').value = "000"
    }
}

function chkTravel_OnClick()
{
    
    if ($('ctl00_holderContent_chkTravel').checked)
    {
        $('ctl00_holderContent_tblAgentField').style.display = "block"
    }else
    {
        $('ctl00_holderContent_tblAgentField').style.display = "none"
    }
}

function ddlWhere_OnClick()
{
    if ($('ctl00_holderContent_ddlWhere').value == "Other")
    {
        $('ctl00_holderContent_txtOther').value = ""
        $('ctl00_holderContent_divOther').style.display = "inline"
        
    }else
    {
        $('ctl00_holderContent_txtOther').value = "-"
        $('ctl00_holderContent_divOther').style.display = "none"
        
    }
}

function bpddlCountry_Change() {
    if ($('ddlCountry').value == "Australia") {
        $('cTxtPostCode').value = ""
        $('thPostcode').style.display = "inline"
        $('tdPostcode').style.display = "inline"
    } else {
        $('thPostcode').style.display = "none"
        $('tdPostcode').style.display = "none"
        $('cTxtPostCode').value = "000"
    }
}

function bpchkTravel_OnClick() {

    if ($('chkTravel').checked) {
        $('tblAgentField').style.display = "block"
    } else {
        $('tblAgentField').style.display = "none"
    }
}

function bpddlWhere_OnClick() {
    if ($('ddlWhere').value == "Other") {
        $('txtOther').value = ""
        $('divOther').style.display = "inline"

    } else {
        $('txtOther').value = "-"
        $('divOther').style.display = "none"

    }
}

