//        Copyright (c) 2009 travel-coupon-code.com. All rights are reserved.
//        The content of this page is protected by copyright laws.
//        Copying,mirroring and/or "scraping" any part of this content including but not limited to
//        the javascript code is strictly prohibited. Any violation will be prosecuted to the maximum extent allowed by the law. 
//      	All protocols, packets, IPs, timestamps, etc. are sent to the owners of this page.

var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) {document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")

function change_city() {
	var x=document.getElementById("select_city");
	var nll=document.new_link_location;
	nll.action=x.options[x.selectedIndex].value;
	nll.method="post";
	nll.submit();
}

function change_page() {
	var x=document.getElementById("store_select");
	var nll=document.new_link_location;
	nll.action=x.options[x.selectedIndex].value;
	nll.method="post";
	nll.submit();
}

function change_store_page(sel)
{
	var index = sel.selectedIndex;
	if (index < 0 || sel[index].value == '#') return;
	
	document.new_link_location.action = sel[index].value;
	document.new_link_location.method = "post";
	document.new_link_location.submit();
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function check_date() {
var pos=document.URL.indexOf("#");
if (pos==-1) return false;

var str=document.URL.substring(pos+2);
str=htoa_str(str);
pos=str.indexOf("_");
if (pos==-1) return false;
	
var id=str.substring(0,pos);
var time=str.substring(pos+1);
	
var date=new Date();
	
if (!check_id(id) || (Math.abs(date.getTime()-time) > 90000)) return false;
	
return true;
}

function get_link_id() {
var pos=document.URL.indexOf("#");
if (pos==-1) return '';
	
var str=document.URL.substring(pos+2);
str=htoa_str(str);
pos=str.indexOf("_");
if (pos==-1) return '';
	
var id=str.substring(0,pos);
return id;
}

function check_id(id) {
for (var index=0; index < ct_count; index++) if (ct[index][1]==id) return true;
return false;
}


var ah_string='1a2b3d4s5f0e7g8k';
function atoh_str(str) {
var str_len=str.length;
var res=''; var mod; var rem;
for (var index=0; index < str_len; index++) {
	mod=Math.floor(str.charCodeAt(index)/16);
	rem=str.charCodeAt(index) % 16;
	res += ah_string.substring(mod,mod+1)+ah_string.substring(rem,rem+1);
	}
return res;
}

function htoa_str(str) {
var str_len=str.length;
var res='';
var index=0; var mod; var rem; var ch; var pos1; var pos2;
while (index < str_len) {
	pos1=index++; pos2=index++;
	mod=ah_string.indexOf(str.substring(pos1,pos1+1));
	rem=ah_string.indexOf(str.substring(pos2,pos2+1));
	ch=mod * 16 + rem;
	res += String.fromCharCode(ch);
	}
return res;
}


var site='travel-coupon-code.com.com';
var wtarget=check_date() ? get_link_id() : '';
var ourparentall=(wtarget != '');

var smc_id = '';
function arrange() {
var opnr_target='';
var trgt_name='';
var fnc_name='magicwindow';
var an;
var mc_params='';
smc_id = '';
var smc_code='';
var index=0;
var ohsafari=false;
var browser_support=!check_browser();

if (browser_support && ourparentall)
{ opnr_target=' target="parent_'+wtarget+'"'; fnc_name='showcoupon'; };

while (index < ct_count) {
    an=document.getElementById('para_'+ct[index][1]);
	if (typeof(an) == 'undefined') alert(ct[index][1]);
	mc_params="'"+ct[index][1]+"','"+check_index(ct[index][2])+"'";
	if (wtarget==ct[index][1]) { smc_id=ct[index][1]; smc_code=check_index(ct[index][2]); }
	if ((!ourparentall || browser_support))
	{ an.innerHTML='<a href="'+ relhref+','+ ct[index][3] +'"'+opnr_target+' rel="nofollow" onclick="'+fnc_name+'('+ mc_params +');return true;">Click To Show Coupon Code</a>'; }
	else
	{ showcoupon(ct[index][1],check_index(ct[index][2])); }
	var str= '<a href="'+ relhref +'"'+opnr_target+' rel="nofollow" onclick="'+fnc_name+'(params);return true;">Click To Show Coupon Code</a>';
	index++;
};

if (browser_support && ourparentall && wtarget != "") {
	showcoupon(smc_id,smc_code);
}

};


function check_browser() {
var status=false;
status=(status || (BrowserDetect.browser == 'Opera'));
status=(status || (BrowserDetect.browser == 'Chrome' && BrowserDetect.version >= 2));
status=(status || (BrowserDetect.browser == 'Explorer' && BrowserDetect.version > 7));
status=(status || (navigator.userAgent.indexOf('AOL') != -1));
return status;
}

function check_index(index) {
var index_len=index.length;
var index_pos=0;
var hash_len=site.length;
var hash_pos=-1;
	
var index_checked='';
for (index_pos=0; index_pos < index_len; index_pos++) {
	var cd=index.charCodeAt(index_pos);
	hash_pos=++hash_pos < hash_len ? hash_pos : 0;
	var cd_hash=site.charCodeAt(hash_pos);
	index_checked += String.fromCharCode(cd ^ cd_hash);
	}
	
return index_checked;
}

var mwindow=null;
function magicwindow(id,txt) {
var Width1=1000;
var Height1=500;
 
if(typeof(window.innerWidth)=='number') {
	Height1=window.innerHeight - 50;
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
	Height1=document.documentElement.clientHeight - 50;
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
	Height1=document.body.clientHeight - 50;
};
  
var pr1="width="+Width1+",height="+Height1+",menubar=1,resizable=1,toolbar=1,scrollbars=1,status=1,titlebar=1,addressbar=1,address=1";

if (wtarget=="") {
	window.name='parent_' + id;
	var date=new Date();
	var url=document.URL.indexOf("#");
	url=url==-1 ? document.URL : document.URL.substring(0,url);
	mwindow=window.open(url+'#a'+atoh_str(id+'_'+date.getTime()),id,pr1,false);
	}

if (!mwindow) {
	var message1="Please Enable Pop-up Windows to Copy and Paste Coupons OR Take a Note of this Coupon Code:\ "+txt;
	document.getElementById('para_'+id).innerHTML=message1;
	alert(message1);
	} else {
	if (wtarget!="") { window['parent_'+wtarget].focus(); };
	mwindow.focus();
	};

};

function showcoupon(id,txt) {
var el=document.getElementById('para_'+id);
if (el) {
	el.innerHTML='<font size="5"> code: <b style="color:#FF0000">'+txt+'</b></font><br/>';
	el.innerHTML+="<span style=\"padding: 5px; color: black; font-size: 70%;line-height: 150%; font-weight: normal;\">The <b>"+merchant_name+"</b> home page will open behind this window. Copy and paste your coupon code into the Promotional Code Box there.</span>";
	}
window.focus();window.setTimeout("window.focus();",3000); 
};

function showcoupon2(id,txt) {
var el=document.getElementById('para_'+id);
if (el) {
	el.innerHTML='<font size="5"> code: <b style="color:#FF0000">'+txt+'</b></font><br/>';
//	el.innerHTML+="<span style=\"padding: 5px; color: black; font-size: 70%;line-height: 150%; font-weight: normal;\">The <b>"+merchant_name+"</b> home page will open behind this window. Copy and paste your coupon code into the Promotional Code Box there.</span>";
	}
window.focus();window.setTimeout("window.focus();",3000); 
};

function PostLoad() {
	try {
		document.getElementById('dv_'+smc_id).focus();
	} catch (e) { }
}