// ========================= Go Away Old Browsers ===============
if (!document.getElementById) {
	window.location="http://www.webstandards.org/upgrade";
}
// ========================= Go Away Old Browsers ===============


// ========================= Invalidable CSS ===============
// invalidable.js  <-- note the extension
//
// Dynamically Inserts CSS Link Tag
var headTag = document.getElementsByTagName("head")[0];
var linkTag = document.createElement('link');
linkTag.type = 'text/css';
linkTag.rel = 'stylesheet';
linkTag.href = 'includes/styles/invalidable.css';
linkTag.media = 'screen';
headTag.appendChild(linkTag);
// ========================= Invalidable CSS ===============


//========================= Quick Reference =====================
function SelectQuickReference() {
	str_quick_ref=document.forms["frmQuickReference"].lstQuickRef.options[document.forms["frmQuickReference"].lstQuickRef.selectedIndex].value;
	if (str_quick_ref=="n") {
		return false;
	}
	else {
		window.location=str_quick_ref;
		return true;
	}
}
//========================= Quick Reference =====================


//========================= Validate Search Box =================
function SearchProductValidation() {
	itc=document.forms["frmSearchForm"].txtSearchString.value.toLowerCase();
	if (itc==""||itc.length<3) {
		window.alert("What Do You Want To Search ? Please Type At Least 3 Characters...");
		document.forms["frmSearchForm"].txtSearchString.focus();
		return false;
	}
	else {
		return true; 
	} 
}
//========================= Validate Search Box =================


//========================= Preloading Images ===================
function MM_preloadImages() {
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//========================= Preloading Images ===================


//========================= Window ================================
function MiniWindowOpen(WhatWin,WID,HEI) {
	open(WhatWin,'miniwin','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=0,width=' + WID + ',height=' + HEI);
}
//========================= Window ================================


//========================= Feedback ================================
function Feedback() {
	MiniWindowOpen('http://www2.singersl.com/singer/includes/asps/website_feedback.asp','410','390');
}
//========================= Feedback ================================


//========================= Tell Friend ================================
function TellFriend() {
	MiniWindowOpen('http://www2.singersl.com/singer/includes/asps/tell_friend.asp?txtURL=' + window.location,'410','390');
}
//========================= Tell Friend ================================


//========================= Mega Seasonal Catalogue ================================
function MegaSeasonalCatalogue() {
	//MiniWindowOpen('http://www2.singersl.com/singer/includes/asps/mega_seasonal_catalogue.asp','550','300');
	//MiniWindowOpen('http://www.singermega.com/register/register.php','550','300');
	MiniWindowOpen('http://www.singermega.com/avurudu2010/register.html','515','650');
}
//========================= Mega Seasonal Catalogue ================================


//======================================================================
// ========== These functions will show & hide form contents when submitting. ==========
//======================================================================
// The name of the element to be shown is passed to this
// function. It then removes the none styling of the
// element, thus showing it.
var isDivHidden;
function showContent(myElement) {
	if(document.getElementById(myElement)) {
		if(isDivHidden==false) {
			hideContent(myElement);
		}
		else {
			document.getElementById(myElement).style.display="";
			isDivHidden = false;
			//document.body.style.cursor="wait";
			//window.alert("showContent");
		}
	}
}

// Change the style of the element passed to the function
// to none, which hides it.
function hideContent(myElement) {
	if(document.getElementById(myElement)) {
		document.getElementById(myElement).style.display="none";
		isDivHidden = true;
		//document.body.style.cursor="wait";
		//window.alert("hideContent");
	}
}

// Calls both the hideContent and showContent functions, then submits the form.
function submitFormContents() {
	hideContent("tblSubmit");
	document.body.style.cursor="wait";
	showContent("tblSubmitting");
}
//======================================================================
// ========== These functions will show & hide form contents when submitting. ==========
//======================================================================


//========================= Shopping Cart Items ================================
var xmlHttp

function fnShowShoppingCartItems(page_name,var_name,load_text) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
  	{
  	alert ("Your browser does not support AJAX!");
  	return;
  	}
  	document.getElementById("DivChangeArea").innerHTML=load_text;
	var url=page_name;
	url=url+"?"+var_name;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged() { 
	if (xmlHttp.readyState==4)
	{
	document.getElementById("DivChangeArea").innerHTML=xmlHttp.responseText;
	}
}

function GetXmlHttpObject() {
	var xmlHttp=null;
	try
  	{
  	// Firefox, Opera 8.0+, Safari
  	xmlHttp=new XMLHttpRequest();
  	}
	catch (e)
  	{
  		// Internet Explorer
  		try
    		{
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		}
  		catch (e)
    		{
    		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		}
  	}
	return xmlHttp;
}
//Function to call the ASP and load the Shopping Cart items...
//============================================================


//========================= XssHttpRequest For AJAX ================================
/* XssHttpRequest version 1.0
 * (c) 2005 Jeffrey Sambells <info@jeffreysambells.com>
 *
 * XssHttpRequest is freely distributable under the terms of an MIT-style license.
 * For details, see the XssHttpRequest web page: http://jeffreysambells.com/XssHttpRequest
 */
var XssHttpRequestCount=0;
var XssHttpRequestWatchList=[];
var X=function(){this.ins=++XssHttpRequestCount;this.u;this.so;this.w;this.wc=0;this.to=30;this.responseText=null;this.responseXML=null;this.status=null;this.readyState=0;};
X.prototype.onreadystatechange=function(){};
X.prototype.onerror=function(){};
X.prototype.onload=function(){};
X.prototype.ss=function(s){this.status=s;};
X.prototype.srs=function(a){if(this.readyState<a||a==0){this.readyState=a;this.onreadystatechange();if(this.readyState=='2'){this.srs(3);eval("if(typeof XssHttpRequest"+this.ins+"Loaded!='undefined'){this.responseText=XssHttpRequest"+this.ins+"Loaded;this.ss('200');}else{alert('invalidresponsefromserver.');}");this.so.parentNode.removeChild(this.so);this.srs(4);this.onload();}}};
X.prototype.open=function(m,u,n){this.u=u;this.so=document.createElement('script');this.so.setAttribute('id','XssHttpRequest'+this.ins);if(navigator.userAgent.indexOf('Safari')){this.so.setAttribute('charset','utf-8');}};
X.prototype.send=function(){this.srs(1);this.so.setAttribute('type','text/javascript');this.so.setAttribute('src',this.u+((this.u.indexOf('?')!=-1)?'&':'?')+'XssHttpRequestVar=XssHttpRequest'+this.ins+'Loaded');this.so=document.getElementsByTagName('head')[0].appendChild(this.so);XssHttpRequestWatchList[this.ins]=this;this.w=setInterval('XssHttpRequestWatchList['+this.ins+'].wl()',1000);};
X.prototype.wl=function(){this.wc++;eval("if(typeof XssHttpRequest"+this.ins+"Loaded!='undefined'){clearInterval(this.w);this.srs(2);}else if(this.wc==this.to){clearInterval(this.w);this.onerror('TimedOut');}");};
var XssHttpRequest=X;
//========================= XssHttpRequest For AJAX ================================


//========================= Contents Load From ASP Via AJAX ================================
function doRequest(page_name,var_name,load_text,place_id) {
    request = new XssHttpRequest();
    document.getElementById(place_id).innerHTML=load_text;
    request.open("GET", page_name+var_name, true);
    request.onreadystatechange=function() {
        if(request.readyState==4) {
            document.getElementById(place_id).innerHTML=request.responseText;
        }
    }
    request.send(null);
}
//========================= Contents Load From ASP Via AJAX ================================


//========================= Login Status Load From ASP Via AJAX ================================
function doLoadLoginStatus(page_name,var_name,load_text,place_id) {
	LoadLoginStatus = new XssHttpRequest();
	document.getElementById(place_id).innerHTML=load_text;
	LoadLoginStatus.open("GET", page_name+var_name, true);
	LoadLoginStatus.onreadystatechange=function() {
		if(LoadLoginStatus.readyState==4) {
			document.getElementById(place_id).innerHTML=LoadLoginStatus.responseText;
		}
	}
	LoadLoginStatus.send(null);
}
//========================= Login Status Load From ASP Via AJAX ================================


//========================= Right Section ================================
function doDisplayRightSection() {
	document.write("<iframe id=\"frmAdvertisements\" src=\"http://www2.singersl.com/singer/advertisements/advertisements.asp\" width=\"100%\" height=\"1200\" frameborder=\"0\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\"><p>Your browser does not support iframes.</p></iframe>");
	//document.write("<table width=\"205\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td width=\"15\" height=\"15\"><img src=\"images/oval_rect_bot_left_corner.png\" alt=\"\" width=\"15\" height=\"15\" /></td><td background=\"images/oval_rect_bot_bar.png\"><img src=\"images/pix_trans.gif\" alt=\"\" width=\"15\" height=\"15\" /></td><td width=\"15\" height=\"15\"><img src=\"images/oval_rect_bot_right_corner.png\" alt=\"\" width=\"15\" height=\"15\" /></td></tr></table>");
	document.write("<img src=\"images/pix_trans.gif\" alt=\"\" width=\"15\" height=\"15\" />");
}
//========================= Right Section ================================

//======================================================================
//===== © 2009 Singer (Sri Lanka) PLC. All Rights Reserved.