function ShowConfirmationMessage(textToShow, height, showOrNot)
{
	//alert("chris");
	//if ( showOrNot == "true" )
		//confirmationWindow = dhtmlmodal.open('ConfirmationWindow', 'iframe', '/ajax/confirmationMessage.aspx?textToShow=' + textToShow, '', 'width=705px,height=' + height + 'px,center=1,resize=0,scrolling=1')
}


function GotoLink(where)
{
	window.location.href = where;
}


function OpenLogin(windowTitle, qsValue)
{
	loginLayer = dhtmlmodal.open('LoginLayer', 'iframe', '/login/loginLayer.aspx?qsValue=' + qsValue, windowTitle, 'width=387px,height=155px,center=1,resize=0,scrolling=0')
}


function OpenForgotPassword(windowTitle)
{
	forgotPasswordLayer = dhtmlmodal.open('ForgotPasswordLayer', 'iframe', '/login/forgotPasswordLayer.aspx', windowTitle, 'width=486px,height=123px,center=1,resize=0,scrolling=0')
}


function ValidateSearch(searchTextBoxID, cmbWhereID)
{

	textToSearch = document.getElementById(searchTextBoxID).value;
	collectionID = document.getElementById(cmbWhereID).value;
	
	if ( textToSearch.length < 3 )
		window.location = "/search/advancedSearch.aspx?query=none";
	else if ( (collectionID == 0) && (textToSearch.length >= 3) )
		window.location = "/search/results.aspx?query=" + textToSearch;
	else if ( (collectionID != 0) && (textToSearch.length >= 3) )
		window.location = "/search/results.aspx?query=" + textToSearch + "&collectionFilter=" + collectionID;
		
}


function ValidateAdvancedSearch()
{
	

	textToSearch = document.forms[0].ctl00$cphMain$ctl00$txtQuery.value;
	textToSearch = textToSearch == "" ? " " : textToSearch;
	colourToSearch = document.forms[0].ctl00$cphMain$ctl00$txtColour.value;
	sizeToSearch = document.forms[0].ctl00$cphMain$ctl00$txtSize.value;
	brandToSearch = document.forms[0].ctl00$cphMain$ctl00$txtBrand.value;
	minPrice = document.forms[0].ctl00$cphMain$ctl00$txtPriceFrom.value;
	minPrice = minPrice == "" ? "0" : minPrice;
	maxPrice = document.forms[0].ctl00$cphMain$ctl00$txtPriceTo.value;	
	maxPrice = maxPrice == "" ? "50000" : maxPrice;

	level1 = document.forms[0].ctl00$cphMain$ctl00$cmbBoutique.value;
	level2 = "0";
	
	if ( document.forms[0].ctl00$cphMain$ctl00$rblCategories != null )
	{

		for (i = 0; i < document.forms[0].ctl00$cphMain$ctl00$rblCategories.length; i++)
		{
			if (document.forms[0].ctl00$cphMain$ctl00$rblCategories[i].checked == true)
				level2 = document.forms[0].ctl00$cphMain$ctl00$rblCategories[i].value;
		}
	
	}
	
	if ( (textToSearch != " ") || (colourToSearch != "") || (sizeToSearch != "") || (brandToSearch != "") || (minPrice != "0") || (maxPrice != "1000") )
		window.location = "/search/results.aspx?query=" + textToSearch + "&collectionFilter=" + level1 + "&collectionFilterL2=" + level2 + "&colour=" + colourToSearch + "&brand=" + brandToSearch + "&size=" + sizeToSearch + "&minPrice=" + minPrice + "&maxPrice=" + maxPrice;
	else
		window.location = "/search/advancedSearch.aspx?query=emptyform";

}


function ShowForgotPassword()
{

	forgotPassword = document.getElementById("login-divForgotPassword");

	if ( forgotPassword.style.display != "none" )
		forgotPassword.style.display = "none";
	else
		forgotPassword.style.display = "block";

}


function ShowCreatePassword()
{

	createPassword = document.getElementById("login-divCreatePassword");

	if ( createPassword.style.display != "none" )
		createPassword.style.display = "none";
	else
		createPassword.style.display = "block";

}


function openPopUp(url, name, w, h)
{

	w += 32;
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	if (wleft < 0)
	{
		w = screen.width;
		wleft = 0;
	}

	if (wtop < 0)
	{
		h = screen.height;
		wtop = 0;
	}

	var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' +
	'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' +
	'status=no, toolbar=no, scrollbars=yes, resizable=no');

	win.resizeTo(w, h);
	win.moveTo(wleft, wtop);
	win.focus();

}


function openPopUpNoScrollBar(url, name, w, h)
{

	w += 32;
	h += 96;
	wleft = (screen.width - w) / 2;
	wtop = (screen.height - h) / 2;

	if (wleft < 0)
	{
		w = screen.width;
		wleft = 0;
	}

	if (wtop < 0)
	{
		h = screen.height;
		wtop = 0;
	}

	var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' +
	'left=' + wleft + ', top=' + wtop + ', ' + 'location=no, menubar=no, ' +
	'status=no, toolbar=no, scrollbars=no, resizable=no');
    
    //-- IE 6 problem: win is null --//
    if(win!=null)
    {
	    win.resizeTo(w, h);
	    win.moveTo(wleft, wtop);	
	    win.focus();
	}

}


function IncreaseFont()
{
	divTop = document.getElementById("divDescriptionTop");
	fontSize = divTop.style.fontSize != "" ? divTop.style.fontSize.substring(0, 2) : "11";
	divTop.style.fontSize = parseInt(fontSize)+1 + "px";

	divBottom = document.getElementById("divDescriptionBottom");
	divBottom.style.fontSize = parseInt(fontSize)+1 + "px";
}


function DecreaseFont()
{
	divTop = document.getElementById("divDescriptionTop");
	fontSize = divTop.style.fontSize != "" ? divTop.style.fontSize.substring(0, 2) : "11";
	divTop.style.fontSize = parseInt(fontSize)-1 + "px";

	divBottom = document.getElementById("divDescriptionBottom");
	divBottom.style.fontSize = parseInt(fontSize)-1 + "px";
}


function UpperText(textBoxToUpper)
{

	//
	// http://daniellarson.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&_c=BlogPart&partqs=amonth%3D11%26ayear%3D2006
	// http://tlt.its.psu.edu/suggestions/international/bylanguage/greekchart.html
	//

	textBoxToUpper.value = textBoxToUpper.value.toUpperCase();

	for ( i = 0; i < textBoxToUpper.value.length; i++ )
	{
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(902),String.fromCharCode(0x0391)); // ALPHA
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(904),String.fromCharCode(0x0395)); // EPSILON
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(905),String.fromCharCode(0x0397)); // ETA
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(906),String.fromCharCode(0x0399)); // IOTA
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(908),String.fromCharCode(0x039f)); // OMICRON
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(910),String.fromCharCode(0x03a5)); // UPSILON
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(911),String.fromCharCode(0x03a9)); // OMEGA
		textBoxToUpper.value = textBoxToUpper.value.replace(String.fromCharCode(962),String.fromCharCode(931));
	}

}


function ProperText(textBoxToUpper)
{
    textBoxToUpper.value = textBoxToUpper.value.toProperCase();
}


function CheckKeyCode(event)
{

	var Key = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;

	if ( (Key == 189 || Key == 109) ||
	     (Key >= 48 && Key <= 57) ||
	     (Key == 8) || (Key == 9) ||
	     (Key == 17) || (Key == 116) ||
	     (Key == 8) || (Key == 46) ||
	     (Key == 17) || (Key == 86) ||
	     (Key >= 37 && Key <= 40) ||
	     (Key >= 96 && Key <= 105) ||
	     (Key == 13) )
	{
		return true;
	}
	else
	{	
		return false;
	}
	
}


function CheckGreekCharacters(e)
{

	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /\d/;
	return !reg.test(keychar);

}


function ExpandInformation(image, divNumber)
{

	currentStatus = document.getElementById("divInformation" + divNumber).style.display;

	if ( currentStatus == "none" )
	{
		document.getElementById("divInformation" + divNumber).style.display = "block";
		image.src = "/cms/images/faq-Collapse.gif";
		margin = document.getElementById("divFooterMargin").style.marginTop;

		if ( margin == "" )
			document.getElementById("divFooterMargin").style.marginTop = "50px";
		else
		{
			currentMargin = parseInt(margin.substring(0, margin.indexOf("px")));
			currentMargin += 1;
			document.getElementById("divFooterMargin").style.marginTop = currentMargin + "px";
		}									
	}
	else
	{
		document.getElementById("divInformation" + divNumber).style.display = "none";
		image.src = "/cms/images/faq-Expand.gif";
		margin = document.getElementById("divFooterMargin").style.marginTop;

		if ( margin != "" )
		{
			currentMargin = parseInt(margin.substring(0, margin.indexOf("px")));
			currentMargin -= 1;
			document.getElementById("divFooterMargin").style.marginTop = currentMargin + "px";
		}									
	}

}


function WishListSelectAll()
{
	
	var formElements = document.forms[0].elements;
	
	for(i = 0; i < formElements.length; i++)
	{
		if ( formElements[i].name.indexOf("chkDelete") != -1 )
		{
			if ( formElements[i].checked == true )
				formElements[i].checked = false;
			else
				formElements[i].checked = true;
		}
	}

}


function RedirectToSearch(collectionFilter)
{
	query = document.getElementById("ctl00_cphMain_ctl00_ctl15_txtQuickSearch").value;
	
	if ( query != "" )
		window.location = "/search/results.aspx?query=" + query + "&collectionFilter=" + collectionFilter;
}


function SHP_CheckForEnterKey(event, collectionFilter, buttonClick, sessionGUID, moduleName, moduleGuid, collectionID)
{
	if ( (buttonClick) || (event.keyCode == 13) )
	{
		LogModuleClick(sessionGUID, moduleName, moduleGuid, collectionID);
		RedirectToSearch(collectionFilter);
		return false;
	}
	else
		return true;
}


function SHP_CheckForEnterKeyNews(event, location, buttonClick, sessionGUID, moduleName, moduleGuid, collectionID)
{	

	if ( (buttonClick) || (event.keyCode == 13) )
	{
		LogModuleClick(sessionGUID, moduleName, moduleGuid, collectionID);
		window.location = location;
		return false;
	}
	else
		return true;
}


function URLEscape(url)
{    
    return url.replace(/\?/g, "$**$").replace(/&/g,"$*$");
}


function openTermsAndConditions(openOrNot)
{

	document.forms[0].hidShowTermsPopUp.value = "false";

	if ( openOrNot == "true" )
		termsWindow = dhtmlmodal.open('TermsWindow', 'iframe', '/webAccount/registerTerms.aspx', '', 'width=650px,height=565px,center=1,resize=0,scrolling=1');

}


function LogVisit(sessionGUID,sessionID,source,customerCode)
{

    /*
    var b_lang = navigator.userLanguage;
    var os = navigator.oscpu;
    var resolution = screen.width + " x " + screen.height;
    */
    
    var browser = navigator.userAgent;
    var refer = document.referrer;
    var currentURL = document.location.pathname+document.location.search; //page+query string
    currentURL=URLEscape(currentURL);
    refer=URLEscape(refer);
    port="";
    if (document.location.port)
    {
        port=":"+document.location.port;
    }

    var logURL= "http://"+document.domain+port+"/logging/VisitLog.aspx?ran="+Math.random();
    var qstring = "&uastring="+browser+"&referrer="+refer+"&currentPage="+currentURL+"&sessionid="+sessionID+"&visitorGuid="+sessionGUID+"&source="+source+"&customerCode="+customerCode;

    var img = new Image(0,0);
    img.src=logURL+qstring;
    
}


function getAjaxRequest()
{
    
    var r
    
    r=false;        
    
    if (window.XMLHttpRequest)
    {
        try 
        {
            r=new XMLHttpRequest();
        }
        catch (e)
        {
            r=false;
        }
    }
    
    if (window.ActiveXObject)
    {
        try
        {                
            r =  new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
            r=false;
        }
    }
    
    return r;
    
}


function LogModuleClick(sessionGUID,moduleName,moduleGuid,collectionID)
{
    var logURL= "http://"+document.domain+"/logging/moduleclicklog.aspx?ran="+Math.random();    
    var qstring = "&sessionid="+sessionGUID+"&module="+moduleName+"&moduleGuid="+moduleGuid+"&collectionID=" + collectionID+ "&actionid=1";    
    var req=getAjaxRequest();
    req.onreadystatechange=function(){};
    req.open("GET",logURL+qstring);
    req.send(null);
}


function ChangeSizeCustomisation()
{

	radFemale = document.getElementById("ctl00_cphMain_ctl00_radFemale");
	radMale = document.getElementById("ctl00_cphMain_ctl00_radMale");
	
	if ( radFemale.checked )
	{
		document.getElementById("divFemale").style.display = "block";
		document.getElementById("divMale").style.display = "none";
	}
	else
	{
		document.getElementById("divFemale").style.display = "none";
		document.getElementById("divMale").style.display = "block";
	}

}


String.prototype.toProperCase = function()
{
 	return this.toLowerCase().replace(/^(.)|\s(.)/g, 
		function($1) { return $1.toUpperCase(); });
}


function ProperText(fld)
{
    fld.value = fld.value.toProperCase();
}


function getAjaxRequest()
{

    var r
    r=false;        
    
    if (window.XMLHttpRequest)
    {
        
        try 
        {
            r=new XMLHttpRequest();
        }
        catch (e)
        {
            r=false;
        }
        
    }
    
    if (window.ActiveXObject)
    {
        
        try
        {                
            r =  new ActiveXObject("Microsoft.XMLHTTP");
        }
        
        catch (e)
        {
            r=false;
        } 
        
    
    }
    return r;

}


function ExitPopup()
{	
	window.open("/popups/exitpopup.aspx",'','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=100,height=100').blur();
}


function OpenAddToCartPopUp(refCode)
{
	addToCartWindow = dhtmlmodal.open("AvailGrid", "iframe", "/popups/addToCart.aspx?refCode=" + refCode, "", "width=950px,height=190px,center=1,resize=0,scrolling=1");
}

//Used to set the hiddenfield 'hidCurrentFlyOutId' value to current menu item collectionID.
function MenuItemsMouseOver(id) 
{
    document.getElementById(hidCurrentFlyOutId).value = id;
}

