// JavaScript Document for Webdunia Photogallery - GR@Creative
/* -------------- Property Bar Fade-In Fade-Out -----------------*/

var wbdUtils = {};
wbdUtils.DOM = {};

wbdUtils.DOM.getElementsByClassName = function(clsName, tag, elm){
	var testClass = new RegExp("(^|\\s)" + clsName + "(\\s|$)");
	var tag = tag || "*";
	var elm = elm || document;
	var elements = (tag == "*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
	var returnElements = [];
	var current;
	var length = elements.length;
	for(var i=0; i<length; i++){
		current = elements[i];
		if(testClass.test(current.className)){
			returnElements.push(current);
		}
	}
	return returnElements
}

var tfade;
    function myfade(val){
		if(val==1){
		document.getElementById('dv2').style.display='block';
		tfade=setInterval(function(){fade('dv2',val)}, 1)
		}
		else if(val==-1){
		tfade=setInterval(function(){fade('dv2',val)}, 1)
		}
		
	}
    function getOp(id){return parseFloat(document.getElementById(id).style.opacity);}
    function setOp(id, val){var obj = document.getElementById(id).style; obj.opacity=val; var opf =parseInt(val*100);  if(window.ActiveXObject) obj.filter = "alpha(opacity=" + opf + ")"}
    function fade(id,dif){
        var op = getOp(id);
        op = op+.1*dif
        op = op<0?0:op>1?1:op
        setOp(id,op);
        if(op<=0 || op>=1){
			clearInterval(tfade)
			if(op<=0) document.getElementById('dv2').style.display='none';
		}
    }
/*--------------------------------------------------------------*/
var t;
function showHide(action,id){
	if(action=="show"){
		document.getElementById(id).style.display="block";
		document.getElementById(id).focus();
	}
	else if(action=="hide"){
		
		document.getElementById(id).style.display="none";
	}
	
	return false   ;   
}
function moreNxt(){
	document.getElementById("more1").style.display="none";
	document.getElementById("more2").style.display="block";
}
function morePrv(){
	document.getElementById("more2").style.display="none";
	document.getElementById("more1").style.display="block";
}

function hideCommentQuads(){
	document.getElementById("galleryImgInfo").style.display="none";
	document.getElementById("galleryImgInfosmallImages").style.display="none";
	//document.getElementById("ctl00_ContentPlaceHolder1_galleryComment").style.display="none";
	document.getElementById("gallerySend2Friend").style.display="none";
	document.getElementById("arrow").style.display="none";
// me	document.getElementById("commentThanks").style.display="none";
	document.getElementById("mailThanks").style.display="none"   ;   
}

function showImgInfo(){
	hideCommentQuads();
	document.getElementById("galleryImgInfo").style.display="block";
}
function showThanks(){
	hideCommentQuads();
	document.getElementById("commentThanks").style.display="block";
}
function showComment(){
	clearCommentControls();hideCommentQuads();
	document.getElementById("ctl00_ContentPlaceHolder1_galleryComment").style.display="block";
	document.getElementById("arrow").style.display="block";
	document.getElementById("arrow").className="wpg_arrowComment";
}
//function showSend2Friend(){
//	clearSendMailControls();
//	hideCommentQuads();
//	document.getElementById("gallerySend2Friend").style.display="block";
//	document.getElementById("arrow").style.display="block";
//	document.getElementById("arrow").className="wpg_arrowFriend";
//	}


var t;
function showRating(obj){
var tempid = obj.replace('galleryImage' , 'rating1' )   ;   
	document.getElementById(tempid).style.display='block';
}
function hideRating(obj){ 
	document.getElementById(obj).style.display='none';
}
function blurTxt(obj, pFrom ){
var tempid   ;
if (pFrom == 1 ) tempid = obj.replace('galleryImage' , 'rating1' )   ;
else
tempid = obj   ;   
    t = setTimeout("hideRating('"+tempid+"');", 100);
}
function killTimeout(){
    clearTimeout(t);
}

var t2;
function showSubCat(id){
	var subCat = id+"SubCat";
	document.getElementById(subCat).style.display='block';
}
function hideSubCat(id){
	var subCat = id+"SubCat";
	document.getElementById(subCat).style.display='none';
}
function blurSubCat(){
t = setTimeout("hideSubCat('film');", 500);
}
function killTimeout_sub(){
    clearTimeout(t2);
}

function hideSubMenu(){
}

function hideMenu(){
	t = setTimeout("hideSubMenu();", 100);
}

function menuGotFocus(){
	tabRoll ( 'over' , document.getElementById('hdnmenuCat').value    , true    )   ;    
}
 var prevtab = '' ;
 var innerCategoryId;
function tabRoll(action, id , hasChild , palign ){
	var tab = id+"Tab";
	var menu = id+"Menu";
//if (document.getElementById('hdnmenuCat')) document.getElementById('hdnmenuCat').value = id    ;    
//document.getElementById   ('homeTab').className = "";
var url = document.location.toString();
		var spliturl =[];
		spliturl = url.split('/');
	if(action == "over" && document.getElementById(menu))
	{
		hideSubMenu();  
		document.getElementById('tdSubCategoryMenu').innerHTML   =   ""   ;   
		if (hasChild)     
		document.getElementById('tdSubCategoryMenu').innerHTML = document.getElementById(menu).innerHTML   ; 
		if (palign)
		document.getElementById('tdSubCategoryMenu').style.textAlign='left'   ;   
		if ( prevtab != '' )
		document.getElementById(prevtab).className = "";  
		if ( tab != '' )
		document.getElementById(tab).className="wpg_selectedTab";
		prevtab = tab        ;
	    if ( document.location.toString().toLowerCase().search('inner.aspx') > 0 
	          && id != document.getElementById ( 'hdnInnerCategory').value 
	         && innerCategoryId   && document.location.toString().toLowerCase().search('subcategory.aspx')    >    0 
	          && document.location.toString().toLowerCase().search('category.aspx')    >    0  )     
	        { 
	            if(document.getElementById ( 'hdnInnerCategory') != null)
	            innerCategoryId = document.getElementById ( 'hdnInnerCategory').value    ; 
	            document.getElementById(innerCategoryId+"Tab").className="";
	        //    prevtab =    innerCategoryId  + "Tab"   ;   
		        hideMenu();  
	        }
	 }
	if(action == "out")
	{hideMenu();}
	
	if ( action == "hideMenu" )
	{
		if (document.getElementById('tdSubCategoryMenu') != null  && 
		 (  document.location.toString().search('inner.aspx') <= 0 || document.location.toString().toLowerCase().search('subcategory.aspx')    <=    0 ||    document.location.toString().toLowerCase().search('category.aspx')    <=    0 )  )
		{
		if ( document.getElementById(prevtab) != null )
		document.getElementById(prevtab).className="";
		document.getElementById('tdSubCategoryMenu').innerHTML = ""   ;             
		}
//	 if ( document.location.toString().toLowerCase().search('inner.aspx')  > 0 
//	 ||    document.location.toString().toLowerCase().search('subcategory.aspx')    >    0 
//	  ||    document.location.toString().toLowerCase().search('category.aspx')    >    0   )  
	    if ( spliturl.length == 8  || spliturl.length  == 7  ||  spliturl.length == 6      )   
	 {
	    if(document.getElementById ( 'hdnInnerCategory') != null)
	    innerCategoryId = document.getElementById ( 'hdnInnerCategory').value    ; 
	   // alert   (   innerCategoryId   )   ;  
	   // alert (document.location.toString().toLowerCase().search('subcategory.aspx'))   ;    
	   if ( document.getElementById(innerCategoryId+'Tab') != null ) 
	    tabRoll ( 'over' , innerCategoryId   ,   true  , document.getElementById(innerCategoryId+'Tab').name  )    ;   
	 }
	}
	
	
}
/* --------------- FF ----------------------------------------*/
/*if(document.all){
	//alert ("Running IE");
	document.write("<STYLE type='text/css'>.wdn_custDiv{background:#fff; border:1px solid #ccc;width:250px;position:absolute;float:right; padding:5px; margin-left:-142px; margin-top:28px;}</STYLE>");
}
else if((document.all)&&(navigator.appVersion.indexOf('MSIE 7.')!=-1))
{
	//alert("running IE 7");
	document.write("<STYLE type='text/css'>.wdn_custDiv{background:#fff; border:1px solid #ccc;width:250px;position:absolute;float:right; padding:5px; margin-left:-142px; margin-top:28px;}</STYLE>");
}*/
if(document.getElementById){
	//alert ("Running Netscape 6");
	document.write("<STYLE type='text/css'>.kreative{width:90%}</STYLE>");
}
/*--------------------------------------------------------------*/

function menuRoll(action)
{}




//function hideSend2Friend(){

//	document.getElementById("galleryImgInfo").style.display="block";
//	document.getElementById("galleryImgInfosmallImages").style.display="block";
//document.getElementById('gallerySend2Friend').style.display = "none"    ;   
//	
//}
function showSend2Friend(){
	document.getElementById("gallerySend2Friend").style.display="block";
}
function hideSend2Friend(){
	document.getElementById("gallerySend2Friend").style.display="none";
}


//function fEmailFocus(){
//	var cBox = document.getElementById('txtToEmail');
//	if (cBox.innerHTML == "Example: user@webdunia.com; info@webdunia.com"){
//	cBox.innerHTML = "";
//	cBox.className = "wpg_commentBox wpg_reqField wpg_whiteTxt"
//	}
//}
//function fEmailBlur(){
//	var cBox = document.getElementById('txtToEmail');
//	if (cBox.innerHTML == ""){
//	cBox.innerHTML = "Example: user@webdunia.com; info@webdunia.com";
//	cBox.className = "wpg_commentBox wpg_reqField"
//	}
//}

// for channel list
var t;
    function initSm(){
        var objDivs=wbdUtils.DOM.getElementsByClassName('wdp_chSm','div', document.getElementById('tblHeadChannel'));
        for(i=0; i<objDivs.length; i++){
        objDivs[i].style.display = "none";
        }
    }

    function showSm(id){
    killTimeout();
    initSm();
    document.getElementById("chsm"+id).style.display = "block";
    }

    function hideSm(){
    t = setTimeout("initSm()", 500);
    }

    function killTimeout(){
    clearTimeout(t);
    t = "";
    }

    function showCh(){
    document.getElementById("chExpand").style.display = "block";
    document.getElementById("chBtnDown").style.display = "none";
    document.getElementById("chBtnUp").style.display = "block";
    }
    function hideCh(){
    document.getElementById("chExpand").style.display = "none";
    document.getElementById("chBtnUp").style.display = "none";
    document.getElementById("chBtnDown").style.display = "block";
    }