var PHOTO = 0;
var VIDEO = 1;
var TEXT = 2;

self.g_status = PHOTO;

function Show(what) {
	
	if (what == g_status) return;
	
	oTabs = document.getElementsByName("imgTab");
	
	for (var i = 0;i < oTabs.length;i++) {
		//alert(i);
		if (oTabs[i].src.indexOf('2.jpg') > -1) {
				oTabs[i].src = oTabs[i].src.replace(/2/,"1");
				oTabs[i].style.cursor = 'pointer';
		}
		//else if (oTabs[i].src.indexOf('2.jpg') > -1) oTabs[i].src = oTabs[i].src.replace(/2/,"1");
	}
	
	if(arguments[1]) {
		arguments[1].src = arguments[1].src.replace(/1/,"2");
		arguments[1].style.cursor = 'default';
	}
	
	
	try {	
		oComPhoto = document.getElementById("com_photo");
		oComPhoto.className = (what == PHOTO ? "vContent" : "hContent");
	} catch(e) {}
	//alert(oComPhoto.className);	
	
	try {
		oComVideo = document.getElementById("com_video");
		oComVideo.className = (what == VIDEO ? "vContent" : "hContent");
	} catch(e) {}

	try {	
		oComText = document.getElementById("com_text");
		oComText.className = (what == TEXT ? "vContent" : "hContent");	
	} catch(e) {}
	
	
	try {
		
		if (arguments[2]) {
			document.getElementById("video_frame").src = "/mediaplayer/mediaplayer.php?" + arguments[2];
		}
		
	} catch(e) {}
	
	g_status = what;
	//document.getElementById("com_video").className = "vContent";
	
}

function Init() {
	oTabs = document.getElementsByName("imgTab");
	
	for (var i = 0;i < oTabs.length;i++) {
		if (oTabs[i].src.indexOf('2.jpg') > -1) oTabs[i].style.cursor = 'default';
		else oTabs[i].style.cursor = 'pointer';

		oTabs[i].onmouseover = SetPicOver;
		oTabs[i].onmouseout  = SetPicOut;
	}
	
	oHrefs = document.getElementsByTagName("a");
	
	for(var i = 0;i < oHrefs.length;i++) { 
			oHrefs[i].onclick = HighlightLink;
			//oHrefs[i].onmouseover = HighlightLink;
	}
	
	try {
		oList = document.getElementById("pressClippingList");
		oList.onmouseover = SetPreviewPosition;
		oList.onmouseout = PreviwClip;
		
		g_bPressClippinLoaded = true;
		
	} catch(e) {}
	
	
}



function HighlightLink(e) {
	if (! e) e = window.event;
	if (! e) return;

	obj = (e.srcElement ? e.srcElement : e.target);
	obj.style.color = '#0099CC';//'#669900';
}

function SetPicOver(e) {
	
	if (! e) e = window.event;
	if (! e) return;
		
	obj = (e.srcElement ? e.srcElement : e.target);
	
	if (obj.style.cursor != 'default') {

		if (obj.src.indexOf('2.jpg') > -1) {
			obj.src = obj.src.replace(/2/,"1");
		}
		else {
			obj.src = obj.src.replace(/1/,"2");
		}	
	}
}

function SetPicOut(e) {
	if (! e) e = window.event;
	if (! e) return;
	
	obj = (e.srcElement ? e.srcElement : e.target);
	
	if (obj.style.cursor != 'default') {
		
		if (obj.src.indexOf('2.jpg') > -1) {
			obj.src = obj.src.replace(/2/,"1");
		}
		else {
			obj.src = obj.src.replace(/1/,"2");
		}	
	}
}


g_bPressClippinLoaded = false; 
g_Yposition = -1;
g_Xposition = -1;

function SetPreviewPosition(e) {
	if (! e) e = window.event;
	if (! e) return;
	
	g_Yposition = (document.all ? e.y : e.pageY);
	g_Xposition = (document.all ? e.x : e.pageX);
}

function PreviwClip(iindex) {
		
	
	if (! g_bPressClippinLoaded) return;
	
	oDiv = document.getElementById('divClip');
	
	if (isNaN(iindex)) {
		//oDiv.style.width="0px";
		//oDiv.style.height="0px";
		//oDiv.style.overflow="hidden";
		oDiv.style.visibility = 'hidden';
		return;
	}

	oDiv.innerHTML = "<img src='" + g_clips[iindex].src + "' border='0' />"
	yPos = g_Yposition - g_clips[iindex].height;
	if (yPos < 0) yPos = 10;

	oDiv.style.top = (yPos) + "px";
	oDiv.style.left = (g_Xposition + 40) + "px";
	oDiv.style.visibility="visible";

}

