/*-------------------------------------------------------------
@@ JavaScript Document
-------------------------------------------------------------*/

// Debug Site's Hostname
debug_host_list = new Array(
"e-2j.com"
);

// initialize debug flag
debug_flag = false;

// default image path
image_path = "http://www.cslsurgery.com/";

// debug site image path
debug_image_path = "http://www.cslsurgery.com/";

// this hostname
this_hostname = location.hostname;

// checking debug site
for(i = 0; i < debug_host_list.length ; i++){
	if (this_hostname.match(debug_host_list[i])) {
		debug_flag = true;
		image_path = debug_image_path;
	}
}

// swaping image list(filename only)
data = new Array(
"img/.jpg",
"img/.jpg",
"img/.jpg",
"img/.jpg",
"img/.jpg"
);

preload= new Array();
for (i=0; i<data.length; i++)
{
	preload[i] = new Image();
	preload[i].src = image_path + data[i];
}


// pop up window
function html(w,h,html,target) {
	var w1;
	w1 = window.open("", target,"toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no, width="+w+",height="+h);
	w1.location.href=html
	w1.focus();
}

/*pop up window02*/
var pw02;
    function html02(w,h,html) {
 pw02 = window.open(html,"pw02_win","toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=no,copyhistory=0,width="+w+",height="+h);
}

// change image
var easySwapImg = {
	main : function() {
		var img = document.images, ipt = document.getElementsByTagName('input'), i, preLoadImg = [];
		// img elements
		for (i = 0; i <img.length; i++) {
			if ((img[i].src.match(/.*_off\./))||(img[i].style.filter)){
				preLoadImg[preLoadImg.length] = new Image;
				preLoadImg[preLoadImg.length-1].src = img[i].src.replace('_off.', '_ov.');

				img[i].onmouseover = easySwapImg.over;
				img[i].onmouseout  = easySwapImg.out;
				try {img[i].addEventListener('click', easySwapImg.click, false);}
				catch(e){img[i].attachEvent('onclick', (function(el){return function(){easySwapImg.click.call(el);};})(img[i]));}
			}
		}
		// input[image] elements
		for (i = 0; i <ipt.length; i++) {
			if ((ipt[i].src.match(/.*_off\./))&&(ipt[i].getAttribute('type')=='image')){
				preLoadImg[preLoadImg.length] = new Image;
				preLoadImg[preLoadImg.length-1].src = img[i].src.replace('_off.', '_ov.');

				ipt[i].onmouseover = easySwapImg.over;
				ipt[i].onmouseout  = easySwapImg.out;
				try {ipt[i].addEventListener('click', easySwapImg.click, false);}
				catch(e){ipt[i].attachEvent('onclick', (function(el){return function(){easySwapImg.click.call(el);};})(ipt[i]));}
			}
		}
	}
	,
	
	over : function() {
		var imgSrc, preLoadImgSrc;
		if((this.style.filter)&&(this.style.filter.match(/_off\.png/)))//(IE5.5-6 && png)
			this.style.filter = this.style.filter.replace('_off.png', '_ov.png');
		else
			this.src = this.src.replace('_off.', '_ov.');
	},

	out : function(){
		if((this.style.filter)&&(this.style.filter.match(/_ov\.png/)))//(IE5.5-6 && png)
			this.style.filter = this.style.filter.replace('_ov.png', '_off.png');
		else
			this.src = this.src.replace('_ov.', '_off.');
	},
	
	click : function(){
		if((this.style.filter)&&(this.style.filter.match(/_ov\.png/)))//(IE5.5-6 && png)
			this.style.filter = this.style.filter.replace('_ov.png', '_off.png');
		else
			this.src = this.src.replace('_ov.', '_off.');
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}

easySwapImg.addEvent();



//////////////////////////////
// Footer ELEMENTS
//////////////////////////////

function commonFooter(){
document.write('<div id="footer"><div id="footer_in">' +
'<ul>' +
'<li><a href="Javascript:html(\'720\',\'700\',\'http://www.cslsurgery.com/international/policy/index.html\')">Privacy Policy</a></li>' +
'<!--<li><a href="Javascript:html(\'720\',\'700\',\'http://www.cslsurgery.com/international/faq/index.html\')">Site Faq</a></li>-->' +
'</ul>' +
'<div class="copy">&copy; 2010 CSL Behring .</div>' +
'</div></div>')
}

