//for Quick Shop
var frflowers = 'quickshop/frflowers.html'; 
var qchoco = 'quickshop/qchoco.html'; 
var qcakes = 'quickshop/qcakes.html'; 
var sweets = 'quickshop/qsweets.html'; 
var toys  = 'quickshop/qtoys.html'; 
var qapparel = 'quickshop/qapparel.html'; 
var qjewell = 'quickshop/qjewell.html';
var qusa = 'quickshop/qusa-shop.html'; 


var dynamicContent_ajaxObjects = new Array(); 
var jsCache = new Array();
var enableCache = true; 

function ajax_loadContent(divId,pathToFile)
{
  if(enableCache && jsCache[pathToFile]){
    document.getElementById(divId).innerHTML = jsCache[pathToFile];
    return;
  }
  
  var ajaxIndex = dynamicContent_ajaxObjects.length;
  document.getElementById(divId).innerHTML = '<div style=font-size:13px;><br><br><br><img src="gifs/loading.gif"><br>Loading content...</div>';
  dynamicContent_ajaxObjects[ajaxIndex] = new sack();
  dynamicContent_ajaxObjects[ajaxIndex].requestFile = pathToFile;

  dynamicContent_ajaxObjects[ajaxIndex].onCompletion = 
  function(){ ajax_showContent(divId,ajaxIndex,pathToFile); };  

  dynamicContent_ajaxObjects[ajaxIndex].runAJAX();  
  
  
} 

function ajax_showContent(divId,ajaxIndex,pathToFile)
{
  document.getElementById(divId).innerHTML =
    dynamicContent_ajaxObjects[ajaxIndex].response;
  if(enableCache){
    jsCache[pathToFile] = 
    dynamicContent_ajaxObjects[ajaxIndex].response;
  }
  dynamicContent_ajaxObjects[ajaxIndex] = false;
}




function sack(file){
	this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
	this.requestFile = file;
	this.method = "GET";
	this.URLString = "";
	this.encodeURIString = true;
	this.execute = false;

	this.onLoading = function() { };
	this.onLoaded = function() { };
	this.onInteractive = function() { };
	this.onCompletion = function() { };

	this.createAJAX = function() {
		try {
			this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (err) {
				this.xmlhttp = null;
			}
		}
		if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
			this.xmlhttp = new XMLHttpRequest();
		if (!this.xmlhttp){
			this.failed = true; 
		}
	};
	
	this.setVar = function(name, value){
		if (this.URLString.length < 3){
			this.URLString = name + "=" + value;
		} else {
			this.URLString += "&" + name + "=" + value;
		}
	}
	
	this.encVar = function(name, value){
		var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
	return varString;
	}
	
	this.encodeURLString = function(string){
		varArray = string.split('&');
		for (i = 0; i < varArray.length; i++){
			urlVars = varArray[i].split('=');
			if (urlVars[0].indexOf('amp;') != -1){
				urlVars[0] = urlVars[0].substring(4);
			}
			varArray[i] = this.encVar(urlVars[0],urlVars[1]);
		}
	return varArray.join('&');
	}
	
	this.runResponse = function(){
		eval(this.response);
	}
	
	this.runAJAX = function(urlstring){
		this.responseStatus = new Array(2);
		if(this.failed && this.AjaxFailedAlert){ 
			alert(this.AjaxFailedAlert); 
		} else {
			if (urlstring){ 
				if (this.URLString.length){
					this.URLString = this.URLString + "&" + urlstring; 
				} else {
					this.URLString = urlstring; 
				}
			}
			if (this.encodeURIString){
				var timeval = new Date().getTime(); 
				this.URLString = this.encodeURLString(this.URLString);
				this.setVar("rndval", timeval);
			}
			if (this.element) { this.elementObj = document.getElementById(this.element); }
			if (this.xmlhttp) {
				var self = this;
				if (this.method == "GET") {
					var totalurlstring = this.requestFile + "?" + this.URLString;
					this.xmlhttp.open(this.method, totalurlstring, true);
				} else {
					this.xmlhttp.open(this.method, this.requestFile, true);
				}
				if (this.method == "GET"){
  					try {
						this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')  
					} catch (e) {}
				}

				this.xmlhttp.send(this.URLString);
				this.xmlhttp.onreadystatechange = function() {
					switch (self.xmlhttp.readyState){
						case 1:
							self.onLoading();
						break;
						case 2:
							self.onLoaded();
						break;
						case 3:
							self.onInteractive();
						break;
						case 4:
							self.response = self.xmlhttp.responseText;
							self.responseXML = self.xmlhttp.responseXML;
							self.responseStatus[0] = self.xmlhttp.status;
							self.responseStatus[1] = self.xmlhttp.statusText;
							self.onCompletion();
							if(self.execute){ self.runResponse(); }
							if (self.elementObj) {
								var elemNodeName = self.elementObj.nodeName;
								elemNodeName.toLowerCase();
								if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
									self.elementObj.value = self.response;
								} else {
									self.elementObj.innerHTML = self.response;
								}
							}
							self.URLString = "";
						break;
					}
				};
			}
		}
	};
this.createAJAX();
}


//for Home Tabs

function SwitchMenu1(obj){
        if(document.getElementById)
			{
        var el = document.getElementById(obj);
        var ar = document.getElementById("masterdiv").getElementsByTagName("td");
		for (var i=0; i<ar.length; i++){
        if(ar[i].className == "visible") 
			{
        ar[i].className = "invisible";
			}
			}
		document.getElementById(obj).className = "visible";
			}
	 
			}




function img1()
{
document.getElementById('image').style.display="none";
document.getElementById('image2').style.display="block";
document.getElementById('image3').style.display="block";
document.getElementById('image4').style.display="block";
document.getElementById('image5').style.display="block";
document.getElementById('image6').style.display="block";
}


function img2()
{
document.getElementById('image').style.display="none";
document.getElementById('image2').style.display="none";
document.getElementById('image3').style.display="block";
document.getElementById('image4').style.display="block";
document.getElementById('image5').style.display="block";
document.getElementById('image6').style.display="block";
}


function img3()
{
document.getElementById('image').style.display="block";
document.getElementById('image2').style.display="none";
document.getElementById('image3').style.display="none";
document.getElementById('image4').style.display="block";
document.getElementById('image5').style.display="block";
document.getElementById('image6').style.display="block";
}

function img4()
{
document.getElementById('image').style.display="block";
document.getElementById('image2').style.display="block";
document.getElementById('image3').style.display="none";
document.getElementById('image4').style.display="none";
document.getElementById('image5').style.display="block";
document.getElementById('image6').style.display="block";
}

function img5()
{
document.getElementById('image').style.display="block";
document.getElementById('image2').style.display="block";
document.getElementById('image3').style.display="block";
document.getElementById('image4').style.display="none";
document.getElementById('image5').style.display="none";
document.getElementById('image6').style.display="block";
}

function img6()
{
document.getElementById('image').style.display="block";
document.getElementById('image2').style.display="block";
document.getElementById('image3').style.display="block";
document.getElementById('image4').style.display="block";
document.getElementById('image5').style.display="none";
document.getElementById('image6').style.display="none";
}

function img7()
{
document.getElementById('image').style.display="block";
document.getElementById('image2').style.display="block";
document.getElementById('image3').style.display="block";
document.getElementById('image4').style.display="block";
document.getElementById('image5').style.display="block";
document.getElementById('image6').style.display="none";
}


//for Home Search

function check_advanced_search(kw)  {
  error = 0;

  if (kw.length < 3)
	  {
    error_message = "Please enter atleast 3 characters for search";
    error = 1;
  }

  
if(document.quick_search.keywords.value == "Enter Your Keyword") {
		alert ("Please enter your keyword");
		document.quick_search.keywords.focus();
		return false;
	}



  if (error == 1) {
    alert(error_message);
    return false;
  } else {
    return true;
  }
}

function goto_url(thisurl) {
	location.href = thisurl;
}


function empty_keywords()  {
	document.quick_search.keywords.value = '';
    return true;
}


if (document.images)
{
  pic1= new Image(); 
  pic1.src="http://www.indiangiftsportal.com/gifs/loading.gif"; 

  pic2= new Image(); 
  pic2.src="http://www.indiangiftsportal.com/gifs-06-new/red-bg-1.gif"; 

}



function bg()
{
var myWidth="";
if( typeof( window.innerWidth ) == 'number' ) {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
   myWidth = document.body.clientWidth;
   myHeight = document.body.clientHeight;
  }


if(document.getElementById('pd'))
	{
if (800 > myWidth)
{
document.getElementById('pd').style.width="430px";
}

if (800 < myWidth)
{
document.getElementById('pd').style.width="100%";

}

if (myWidth >= 1000 )
{
document.getElementById('tbl').innerHTML='<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" HEIGHT="130"><TR><TD width="20"><IMG SRC="gifs-06/zero.gif" height="1" width="20"></td><TD  WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-gift-hampers.html\'" STYLE="cursor:pointer;cursor:hand;" ><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-with-sweets.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD></TR></TABLE>';
document.getElementById('rb').className="rbg1";

}


if (myWidth >= 1128)
{
document.getElementById('tbl').innerHTML='<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" HEIGHT="130"><TR><TD width="20"><IMG SRC="gifs-06/zero.gif" height="1" width="20"></td><TD  WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-gift-hampers.html\'" STYLE="cursor:pointer;cursor:hand;" ><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-with-sweets.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-threads.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD></TR></TABLE>';
document.getElementById('rb').className="rbg1";
}
			
				



if (myWidth >= 1258)
{
document.getElementById('tbl').innerHTML='<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" HEIGHT="130"><TR><TD width="20"><IMG SRC="gifs-06/zero.gif" height="1" width="20"></td><TD  WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-gift-hampers.html\'" STYLE="cursor:pointer;cursor:hand;" ><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-with-sweets.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-threads.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/lumba-rakhi-for-bhabhi.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD></TR></TABLE>';
document.getElementById('rb').className="rbg";

}

if (myWidth >= 1378)
{
document.getElementById('tbl').innerHTML='<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" HEIGHT="130"><TR><TD width="20"><IMG SRC="gifs-06/zero.gif" height="1" width="20"></td><TD  WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-gift-hampers.html\'" STYLE="cursor:pointer;cursor:hand;" ><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-with-sweets.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/rakhi-threads.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/lumba-rakhi-for-bhabhi.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD><TD STYLE="cursor:pointer;cursor:hand;" WIDTH="130"  ONCLICK="location.href=\'http://rakhi.indiangiftsportal.com/auspicious-rakhis.html\'"><IMG SRC="gifs-06/zero.gif" height="1" width="1"></TD></TR></TABLE>';
document.getElementById('rb').className="rbg";
}
	}
}


function addEvent( obj, type, fn ){ 
   if (obj.addEventListener){ 
	  obj.addEventListener( type, fn, false );
   }
   else if (obj.attachEvent){ 
	  obj["e"+type+fn] = fn; 
	  obj[type+fn] = function(){ obj["e"+type+fn]( window.event ); } 
	  obj.attachEvent( "on"+type, obj[type+fn] ); 
   } 

}

addEvent(window, 'load', bg);
addEvent(window, 'resize', bg);