// JavaScript Document
function init() {
	for (var i=1;i<3;i++) {
		var x = Cookies['cookie' + i];
		if (x) alert('cookie' + i + '\nthat you set on a previous visit, is still active.\nIts value is ' + x);
	}
}
var Cookies = {
	init: function () {
		var allCookies = document.cookie.split('; ');
		for (var i=0;i<allCookies.length;i++) {
			var cookiePair = allCookies[i].split('=');
			this[cookiePair[0]] = cookiePair[1];
		}
	},
	create: function (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=/";
		this[name] = value;
	},
	erase: function (name) {
		confirmed = window.confirm("Do you want to restore default page as a home page on indiabulls website.");
		if(confirmed){
			this.create(name,"",-1);
			//this[name] = "not set";
		}
	}
};
Cookies.init();
function saveIt(name) {
	confirmed = window.confirm("Do you want to create this page as a default page on indiabulls website.");
	if(confirmed){
		var x = location.href;
		Cookies.create(name,x,1);
	}
}
function readIt(name) {
	var homepath=location.href.indexOf('location=home');
	if(document.cookie.length>0){
		if((Cookies[name].length>7)&&(homepath<=0)){
			window.location.href = Cookies[name];
		}
	}
}
function eraseIt(name) {
	Cookies.erase(name);
	//alert('Cookie erased');
}
