﻿function findobj(n, d) {
	var p, i, x;
	if(!d) d = document;
	if((p = n.indexOf("?"))>0 && parent.frames.length) {
		d = parent.frames[n.substring(p + 1)].document;
		n = n.substring(0, p);
	}
	if(x != d[n] && d.all) x = d.all[n];
	for(i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
	for(i = 0; !x && d.layers && i < d.layers.length; i++) x = findobj(n, d.layers[i].document);
	if(!x && document.getElementById) x = document.getElementById(n);
	return x;
}

function toggle_collapse_home(objname,objname2,objname3,objname4) {
	obj = findobj(objname);
	obj2 = findobj(objname2);
	obj3 = findobj(objname3);
	obj4 = findobj(objname4);
	img = findobj(objname+"_img");

	if(obj.style.display == "none") {
		obj.style.display = "";
		obj2.style.display = "none";
		obj3.style.display = "none";
		obj4.style.display = "none";
		img_re = new RegExp("_home_yes\\.gif$");
		img.src = img.src.replace(img_re, '_home_no.gif');
	} else {
		obj.style.display = "none";
		img_re = new RegExp("_home_no\\.gif$");
		img.src = img.src.replace(img_re, '_home_yes.gif');
	}

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function openWindow2(theURL,winName,winWidth,winHeight,features) {
  var w = (screen.width - winWidth)/2;
  var h = (screen.height - winHeight)/2 - 50;
  features = features+',width='+winWidth+',height='+winHeight+',top='+h+',left='+w;
  window.open(theURL,winName,features);
} 


function hideDiv(divName){
	tempDiv = document.getElementById(divName);
	if (!tempDiv) {
		return;
	}
	if (tempDiv.style.display=="block"){
	     tempDiv.style.display="none";
	}
}

function showDiv(divName){
	tempDiv = document.getElementById(divName);
	if (!tempDiv) {
	  return;
	}
	if (tempDiv.style.display=="none"){
		tempDiv.style.display="block";
	 }
}

function clicked_add_icon(video_ID, fromRelated) {
	quicklist_count++;
	var button_name = 'add_button_' + video_ID;
	document.getElementById('quicklist_numb').innerHTML='<img src=/images/ico3.jpg align=absmiddle> <a href=/quicklist><font color=#FFFFFF>點播單 (' + quicklist_count + ')</font></a>';
	document.getElementById(button_name).src='/images/icn_add_done_25x25.png';
	document.getElementById(button_name).blur();
}

function mouse_over_add_icon(video_ID) {
	var button_name = 'add_button_' + video_ID;
	if (document.getElementById(button_name).src.match('done')){
		document.getElementById(button_name).src='/images/icn_add_done_20x20.gif';
	}
	else {
		document.getElementById(button_name).src='/images/icn_add_over_20x20.gif';
	}			
}

function mouse_out_add_icon(video_ID) {
	var button_name = 'add_button_' + video_ID;
	if (document.getElementById(button_name).src.match('done')){
		document.getElementById(button_name).src='/images/icn_add_done_20x20.gif';
	}
	else {
		document.getElementById(button_name).src='/images/icn_add_20x20.gif';
	}			
}

function clicked_del() {
	quicklist_count--;
	document.getElementById('quicklist_numb').innerHTML='<img src=/images/ico3.jpg align=absmiddle> <a href=/quicklist><font color=#FFFFFF>點播單 (' + quicklist_count + ')</font></a>';
}

function cc(){ 
var result= false ; 
if (navigator.cookiesEnabled) return true ; 
document.cookie = "mytest=yes;" ; 
var cookieSet = document.cookie; 
if (cookieSet.indexOf( "mytest=yes" ) > -1) result= true ; 
document.cookie = "" ; 
return result; 
}