var gappName = 'malayalam';
/* For Video Auto loading */
var videos=[];
var isVideoLoadFirstTime=false;
function regVideos(obj,vUrl,type){
if(isVideoLoadFirstTime){OpenRightVideo(obj,vUrl,1)}else{if(obj){videos.push([obj,vUrl,type]);}}}
function loadVideos(){setTimeout(function(){for(var i=0; i<videos.length; i++){if(videos[i][0].parentNode){OpenRightVideo(videos[i][0],videos[i][1],0);isVideoLoadFirstTime=true;}}},2000);}
function OpenRightVideo(obj,vpath,audio)
{
    obj.parentNode.innerHTML="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0'  width='320' height='210' type='application/x-shockwave-flash' id='RightVideoPlayer'><param name='movie' value='/img/cm/video/HomeVideoPlayer.swf?audio="+audio+"&amp;filepath=" + vpath + "' /><param name='FlashVars' value='allowResize=true' /><embed src='/img/cm/video/HomeVideoPlayer.swf?audio="+audio+"&amp;filepath=" + vpath + "' quality='high' wmode='transparent' devicefont='true' bgcolor='#000000' width='320' height='210' name='mediaplayer' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' allowfullscreen='true' /></object>";
}
/* End Video loading */

function deleteDiv(){
    document.getElementById('shoshAd').style.display = "none";
}
var b_version=navigator.userAgent;
var strG=b_version.toString();

if(strG.indexOf('MSIE 6') != -1){
	document.write("<style type='text/css'>img{behavior:url(/img/cm/iepngfix.htc);}</style>");
}


var wbdUrlList = {'www.webdunia.com':'http://malayalam.webdunia.com','msn.webdunia.com':'http://malayalam.webdunia.com','webdunia.com':'http://malayalam.webdunia.com'};
var urlPrefix = wbdUrlList[window.location.hostname] || ""
var language = 'malayalam'
if((document.all)&&(navigator.appVersion.indexOf('MSIE 7.')!=-1))
{
	//alert ("Running IE7");
	document.write("<STYLE type='text/css'>.wdp_tabCurve,.wdp_selectedTabCurve{padding-right:6px;}</STYLE>");
}
if (document.layers) {
	//alert ("Running Netscape 4");
	document.write("<STYLE type='text/css'>.wdp_tabCurve,.wdp_selectedTabCurve{padding-right:6px;}</STYLE>");
}else if(document.all){
	//alert ("Running IE");
	document.write("<STYLE type='text/css'>.wdp_tabCurve,.wdp_selectedTabCurve{padding-right:6px;}</STYLE>");
}else if(document.getElementById){
	//alert ("Running Netscape 6");
	document.write("<STYLE type='text/css'>.wdp_tabCurve,.wdp_selectedTabCurve{padding-right:5px;}</STYLE>");
}else{
	//alert("Older than 4.0 browser.");
	document.write("<STYLE type='text/css'>.wdp_tabCurve,.wdp_selectedTabCurve{padding-right:6px;}</STYLE>");
}
// Common JavaScript Document for WD new layout 2008 - GR@Creative
String.prototype.trim = function() { return this.replace(/^\s*([\S\s]*)\b\s*$/, '$1');};
var wbdUtils = {};
wbdUtils.DOM = {};
wbdUtils.ajax = {};
wbdUtils.data = {};
wbdUtils.ads = {};
wbdUtils.tabHelpers = {};
/* DOM functions */
wbdUtils.DOM.getParentByName = function(obj,name, tagName){
    if(!tagName) tagName= '*';
    if(typeof(obj)=='string') obj = document.getElementById(obj);
    var prnt = obj.parentNode, found=false;
    while(prnt.tagName.toLowerCase() != 'body'){
        var objName = prnt.attributes?prnt.attributes.getNamedItem("name")?prnt.attributes.getNamedItem("name").value:'':'';
        if(found = ((tagName=='*' || prnt.tagName.toLowerCase()==tagName.toLowerCase()) && (name=="" || objName==name))) break;
        prnt = prnt.parentNode;
    }
    return (found?prnt:null);
};
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
};
wbdUtils.DOM.getElementsByName = function(name, tag, elm) {
    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];
        var objName = current.attributes ? current.attributes.getNamedItem("name") ? current.attributes.getNamedItem("name").value : '' : '';
        if (objName != '' && objName == name) {
            returnElements.push(current);
        }
    }
    return returnElements
};
wbdUtils.DOM.getNext = function(obj,tagName){
    if(!tagName) tagName= '*';
    if(typeof(obj)=='string') obj = document.getElementById(obj);
    var nxt = obj.nextSibling, found=false;
    while(nxt){
        if(found = (tagName=='*' ||(nxt.tagName && nxt.tagName.toLowerCase()==tagName.toLowerCase()))) break;
        nxt = nxt.nextSibling;
    }
    return (found?nxt:null);
};
wbdUtils.DOM.getPrev = function(obj,tagName){
    if(!tagName) tagName= '*';
    if(typeof(obj)=='string') obj = document.getElementById(obj);
    var prv = obj.previousSibling, found=false;
    while(prv){
        if(found = (tagName=='*' ||(prv.tagName && prv.tagName.toLowerCase()==tagName.toLowerCase()))) break;
        prv = prv.previousSibling;
    }
    return (found?prv:null);
};
wbdUtils.DOM.registerOnLoad = function(func){
    var prev = window.onload;
    window.onload = function(){ if(prev){prev();}; eval(func);}
}
wbdUtils.DOM.registerOnLoad('loadVideos();');
/*For 24 Dunia*/
wbdUtils.cityNews = {};
wbdUtils.cityNews.url = '';
wbdUtils.cityNews.defUrl = '';
wbdUtils.cityNews.otherNews = ''
wbdUtils.cityNews.Get = function() { return document.getElementById("cityNewsMenu") };
wbdUtils.cityNews.timeOuts = {};
wbdUtils.cityNews.showCities = function(disp, url) {
    var cont = wbdUtils.cityNews.Get();
    if (disp) {
        wbdUtils.cityNews.killTimeout('city');
        wbdUtils.cityNews.load(url)
        cont.style.display = 'block';
    } else {
        wbdUtils.cityNews.timeOuts['city'] = setTimeout(function() {
            cont.style.display = 'none';
        }, 500);
    }
}
wbdUtils.cityNews.killTimeout = function(key) {
    if (wbdUtils.cityNews.timeOuts[key]) {
        clearTimeout(wbdUtils.cityNews.timeOuts[key]);
        wbdUtils.cityNews.timeOuts[key] = null;
    }
}
var dtStamp24D = new Date().valueOf();
wbdUtils.cityNews.load = function(url) {
    url = url || wbdUtils.cityNews.defUrl;
    //var scrObj = document.getElementById("scr24Dunia");
    if (wbdUtils.cityNews.url != url) {
        wbdUtils.cityNews.Get().innerHTML = '<div class="wdp_cLoading"></div>';
        //if(scrObj) scrObj.parentNode.removeChild(scrObj);
        var scrObj = document.createElement('script');
        scrObj.type = 'text/javascript';
        scrObj.defer = 'defer';
        //scrObj.id="scr24Dunia"
        scrObj.src = url + "?v" + dtStamp24D;
        document.body.appendChild(scrObj);
        wbdUtils.cityNews.url = url;
    }
}
wbdUtils.cityNews.loadCities = function(jData) {
    var html = '';
    if (jData.cities) {
        if (jData.prevCities != '') {
            html += '<a href="javascript:wbdUtils.cityNews.showCities(true,\'' + jData.prevCities + '\')" onmouseover="wbdUtils.cityNews.killTimeout(\'news\');wbdUtils.cityNews.hideNews();" onmouseout="wbdUtils.cityNews.showNews(this,false);"><div class="wdp_cNewsArrowBg" align="center" ><img src="/img/cm/cityPointer_up.png"  border="0" alt="Hindi News"/></div></a>'
        }

        for (var c = 0; c < jData.cities.length; c++) {
            var ct = jData.cities[c];
            html += '<div name="News24Dunia" ' + ((c % 2) == 0 ? '' : ' class="wdp_cAlternate"') + '>';
            html += '<div class="wdp_floatRight">';
            html += '<div class="wdp_cNewsDiv" style="display:none" onmouseover="wbdUtils.cityNews.killTimeout(\'news\');" onmouseout="wbdUtils.cityNews.showNews(this,false);">';
            html += '<div class="wdp_cNewsPointer"><div></div></div>';
            html += '<div class="wdp_cNewsQuad">';
            if (ct.articles) {
                html += '<div class="wdp_padding">'
                for (var a = 0; a < ct.articles.length; a++) {
                    var art = ct.articles[a];
                    html += '<div class="wdp_cNewsBull"><a target="' + (art[2] == 0 ? '_self' : '_blank') + '" href="' + art[1] + '"><small>&nbsp;' + art[0] + '</small></a></div>';
                }
                html += '</div>'
                html += '<div class="wdp_cNewsFooter"><a target="_blank" href="' + ct.link + '"><small>' + wbdUtils.cityNews.otherNews + '</small></a></div>'
            }
            html += '</div>'
            html += '</div>'
            html += '</div>'
            html += '<a href="javascript:void(0);" onmouseover="wbdUtils.cityNews.showNews(this,true);" onmouseout="wbdUtils.cityNews.showNews(this,false);"><div class="wdp_cMenuPointer">' + ct.name + '</div></a></div>';
        }
        if (jData.nextCities != '') {
            html += '<a href="javascript:wbdUtils.cityNews.showCities(true,\'' + jData.nextCities + '\')" onmouseover="wbdUtils.cityNews.killTimeout(\'news\');wbdUtils.cityNews.hideNews();" onmouseout="wbdUtils.cityNews.showNews(this,false);"><div class="wdp_cNewsArrowBg" align="center" ><img src="/img/cm/cityPointer_down.png" border="0" alt="Hindi News"></div></a>'
        }
    }
    wbdUtils.cityNews.Get().innerHTML = html;
}
wbdUtils.cityNews.showNews = function(obj, disp) {
    var cObj = wbdUtils.DOM.getParentByName(obj, 'News24Dunia', 'div')
    var newsDiv = wbdUtils.DOM.getElementsByClassName('wdp_cNewsDiv', 'div', cObj)[0];
    if (disp) {
        wbdUtils.cityNews.killTimeout('city');
        wbdUtils.cityNews.killTimeout('news');
        wbdUtils.cityNews.hideNews();
        newsDiv.style.display = 'block';
    } else {
        wbdUtils.cityNews.timeOuts['news'] = setTimeout(function() {
            wbdUtils.cityNews.hideNews();
            wbdUtils.cityNews.Get().style.display = 'none';
        }, 500);
    }
}
wbdUtils.cityNews.hideNews = function() {
    var cont = wbdUtils.cityNews.Get();
    var objs = wbdUtils.DOM.getElementsByClassName('wdp_cNewsDiv', 'div', cont);
    if (objs && objs.length > 0) {
        for (var i = 0; i < objs.length; i++) {
            objs[i].style.display = 'none';
        }
    }
}
/*For 24 Dunia Ends*/
function openGame(gameURL)
{
	window.open(gameURL);  
}
function openGreetings(greetingUrl)
{
    window.open(greetingUrl);  
}

/* Ajax functions */
wbdUtils.ajax.getRequestObject= function(){ 
    var request = null;
    try { request = new XMLHttpRequest(); }
    catch(e){
        try { request = new ActiveXObject("Microsoft.XMLHTTP");}
        catch(e2){
            try { request = new ActiveXObject("Msxml2.XMLHTTP");}
            catch (e3){ alert('Browser not support AJAX'); request = null;}
        }
    } 
    return request;
};
wbdUtils.ajax.Get = function(url,data, callback, errorHandler){
    if(!url || url=='') {
       if(typeof(errorHandler)=='function') errorHandler('Invalid Url');
    } else {
       
        window.status = url;
        url = url +(url.indexOf('?')==-1?'?':'&')+'version='+new Date();
    
        var req = this.getRequestObject();
        if(req){
            req.onreadystatechange = function(){
                if(req.readyState == 4){
                    if(req.status == 200) {
                        if(callback) {callback(req)}; 
                        window.status = '';
                    } else { 
                        if(typeof(errorHandler)=='function') 
                        errorHandler(request.status+' : '+req.statusText);
                    }
                }
            }
            if(data && data !='') {
                var dataArray=new Array();
                for(var key in data) { dataArray.push(key+'='+escape(data[key]))};
                req.open("POST", url,  true); 
                //req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8' ); 
                req.send(dataArray.join('&')); 
            } else {
                req.open("GET", url,  true); 
                req.send(null); 
            }
        }
    
    }
};


/* Data */
wbdUtils.data.template = {};
wbdUtils.data.template['TabLoadingData'] = '<div class="wdp_divWithoutTop" style="text-align:center;  margin-bottom:4px; height:[HEIGHT]px; background:#ffffff;"><img src="/img/cm/loading.gif" height="8" width="151" border="0" style="margin-top:[TOPMARGIN]px;" class="wdp_quadBdr" /><br/><span class="wdp_english">Loading...</span></div>';
wbdUtils.data.template['TabVideoData']='<object width="395" height="180" align="middle" id="DemoVideo" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param value="always" name="allowScriptAccess" /><param name="movie" value="/img/cm/video/VideoPlayer.swf?videoUrl=[VIDEOURL]"/> <param><param value="high" name="quality" /><param value="#ffffff" name="bgcolor" /><embed width="395" height="180" align="middle" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowscriptaccess="always" name="DemoVideo"  bgcolor="#ffffff" quality="high" src="/img/cm/video/VideoPlayer.swf?videoUrl=[VIDEOURL]" /></object>'

wbdUtils.data.cache = {};
wbdUtils.data.cache.add = function(key,value){wbdUtils.data.cache[key] = value;}
wbdUtils.data.cache.get = function(key){return wbdUtils.data.cache[key];}

/* Subscription */
wbdUtils.subcribe= function(obj,url){
    var scrid = "scrSubscription";
    url = "http://wems.webdunia.com/wdsubscription/subscribe.php?listid=9&";
    var name = document.getElementById("txtSubscriptionName").value.trim();
    var email = document.getElementById("txtSubscriptionEmail").value.trim();
    if(name=="") {
        document.getElementById("txtSubscriptionName").focus();
        alert('Please enter name');
    } else if (!isValidEmail(email)) {
        document.getElementById("txtSubscriptionEmail").focus();
        alert('Please enter a valid email');
    } else {
        url += "emailid=" +email+"&fname="+name
        var objHd = document.getElementsByTagName("head")[0];
        var objScr = document.getElementById(scrid)
        if(objScr) objHd.removeChild(objScr);
        objScr = document.createElement("script");
        objScr.type="text/javascript"
        objScr.src = url;
        objScr.id = scrid;
        objHd.appendChild(objScr);
    }
};
function isValidEmail(email){
    var re = /^[^\s()<>@,;:\/]+@[\w\.-]+\.[a-z]{2,}$/i
    return re.test(email);
}
function onSubscribe(resArr){
    var email = document.getElementById("txtSubscriptionEmail").value
    if(resArr[0]==0){
        openWindowCenterScreen('/MainHP/data/reject.htm?'+email, 'Subscription',210,250);
    } else {
       openWindowCenterScreen('/MainHP/data/accept.htm?'+email, 'Subscription',210,450);
    }
}

/* Tab Helpers */
wbdUtils.tabHelpers.showTabDetails = function(obj,source){
    var objCont = wbdUtils.DOM.getParentByName(obj,'div_tab_detail_container','div');
    var objDv =  objCont.getElementsByTagName("div");
    if(objCont.childNodes.length>1) objDv= objCont.childNodes[1];
    var tmpheight=objDv.offsetHeight-(document.all?1:5);
    var topmargin = tmpheight/2-14;
    objDv.innerHTML = wbdUtils.data.template.TabLoadingData.replace("[HEIGHT]",tmpheight).replace("[TOPMARGIN]",topmargin);
    var tmpTd = wbdUtils.DOM.getParentByName(obj,'','td');
    var tmpTr = tmpTd.parentNode;
    var tds = tmpTr.getElementsByTagName("td")
    var td;
    for(var i=0; i<tds.length; i++){
        td = tds[i];
        var objName = td.attributes?td.attributes.getNamedItem("name")?td.attributes.getNamedItem("name").value:'':'';
        if(objName == 'tabSeperator') {
            td.innerHTML = '<div class="wdp_tabSeperator"></div>';
        } else {
            td.className = 'wdp_tab_bg';
        }
    }
    tmpTd.className = 'wdp_selectedTab_bg';
    td = wbdUtils.DOM.getPrev(tmpTd,'td');
    if(td) {td.innerHTML ='';}
    td = wbdUtils.DOM.getNext(tmpTd,'td');
    if(td) {td.innerHTML ='';}
    
    var key = source.replace(/[:\/\.\?\&\=]/ig,"_");
    var data = wbdUtils.data.cache.get(key);
    if(data && data.length>0){
        if(urlPrefix!=""){
            while(data.indexOf('src="/')>-1){
                data = data.replace('src="/','src="' + urlPrefix + '/');
            }
            while(data.indexOf('href="/')>-1){
                data = data.replace('href="/','href="' + urlPrefix + '/');
            }
        }
        objDv.innerHTML = data;
    } else {
        wbdUtils.ajax.Get(source,null,function(resp){
            data = resp.responseText
            wbdUtils.data.cache.add(key,data);
            if(urlPrefix!=""){
                while(data.indexOf('src="/')>-1){
                    data = data.replace('src="/','src="'+ urlPrefix +'/');
                }
                while(data.indexOf('href="/')>-1){
                    data = data.replace('href="/','href="' + urlPrefix + '/');
                }
            }
            objDv.innerHTML = data;
        });
    }
}
wbdUtils.tabHelpers.showRTabDetails = function(obj, source) {
    var objCtd = obj.parentNode;
    if (objCtd.className.indexOf('wdp_closedTabBtn') != -1) {
        var objCtr = objCtd.parentNode;
        var tabDv = wbdUtils.DOM.getParentByName(obj, '', 'div');
        if (tabDv) {
            var objs = wbdUtils.DOM.getElementsByName('spaceDiv', 'td', tabDv)
            for (var i = 0; i < objs.length; i++) {
                objs[i].className = '';
            }
            objs = wbdUtils.DOM.getElementsByName('spaceDiv', 'td', objCtr)
            for (var i = 0; i < objs.length; i++) {
                objs[i].className = 'wdp_closedTabBtn';
            }
            objs = wbdUtils.DOM.getElementsByClassName('wdp_wBtn', 'td', tabDv)
            for (var i = 0; i < objs.length; i++) {
                objs[i].className = 'wdp_wBtn wdp_closedTabBtn';
            }
            objCtd.className = 'wdp_wBtn';
            var objSpcTr = wbdUtils.DOM.getNext(objCtr, 'tr');
            if (objSpcTr) {
                objCtr.parentNode.appendChild(objSpcTr);
            }
            objCtr.parentNode.appendChild(objCtr);
            var contDiv = wbdUtils.DOM.getNext(tabDv, 'div');
            var tmpheight = contDiv.offsetHeight - (document.all ? 12 : 0);
            var topmargin = tmpheight / 2 - 14;
            contDiv.innerHTML = wbdUtils.data.template.TabLoadingData.replace("[HEIGHT]", tmpheight).replace("[TOPMARGIN]", topmargin);

            wbdUtils.ajax.Get(source, null, function(resp) {
                contDiv.innerHTML = resp.responseText;
            });
        }
    }
}
wbdUtils.tabHelpers.hideRTabDetails = function(obj) {

    var contDiv = wbdUtils.DOM.getParentByName(obj, 'container', 'div')
    if (contDiv) { contDiv.innerHTML = ''; }
    var tabDiv = wbdUtils.DOM.getPrev(obj, 'prev')
    var objs = wbdUtils.DOM.getElementsByClassName('wdp_wBtn', 'td', tabDiv)
    for (var i = 0; i < objs.length; i++) {
        objs[i].className = 'wdp_wBtn wdp_closedTabBtn';
    }
    objs = wbdUtils.DOM.getElementsByName('spaceDiv', 'td', tabDiv)
    for (var i = 0; i < objs.length; i++) {
        objs[i].className = '';
    }
}

wbdUtils.search = function(langid){
    var obj = document.getElementById("wiocliteText1");
    if(obj){
        var q = obj.value;
        var url = "http://search.webdunia.com/search.aspx?w=true&lid="+langid+"&q=" +escape(q);
        window.location.href = url;    
    }
}
/* Ads Management */
wbdUtils.ads.collection = [];
wbdUtils.ads.register = function(obj,region,width,height,lang){
    wbdUtils.ads.collection.push({'Container':obj,'Region':region,'Width':width,'Height':height,'Lang':lang});
}
wbdUtils.ads.load = function(){
    var bust, obj;
    for(var idx =0; idx<wbdUtils.ads.collection.length; idx++){
        bust = Math.floor(1000000*Math.random()+1);
        obj = wbdUtils.ads.collection[idx];
        var html = '<iframe src="http://'+obj.Lang+'.webdunia.com/cgi-bin/advertpro/banners.pl?region='+obj.Region+'&bust=' + bust + '&keyword=NULL" height="'+obj.Height+'" width="'+obj.Width+'" marginwidth="0" marginheight="0" vspace="0" hspace="0" frameborder="0" align="middle" scrolling="no">' +
            '<a href="http://'+obj.Lang+'.webdunia.com/cgi-bin/advertpro/blink.pl?region='+obj.Region+'&bust=' + bust + '" target="_blank">' +
            '<img src="http://'+obj.Lang+'.webdunia.com/cgi-bin/advertpro/bimg.pl?region='+obj.Region+'&keyword=NULL&bust=' + bust + '" border="0">' +
            '</a></iframe>';
         obj.Container.parentNode.innerHTML = html;
    }
}

wbdUtils.cookies = {};
wbdUtils.cookies.Set = function( name, value, expires, path, domain, secure ) {
    var today = new Date();
    today.setTime( today.getTime() );
    if ( expires ){
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );
    document.cookie = name + "=" +escape( value ) + 
        ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
        ( ( path ) ? ";path=" + path : "" ) + 
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ( ( secure ) ? ";secure" : "" );
}
wbdUtils.cookies.Get = function ( name ) {
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ){
        return null;
    }
    if ( start == -1 ) {
        return null;
    }
    var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) { 
        end = document.cookie.length;
    }
    return unescape( document.cookie.substring( len, end ) );
}
wbdUtils.cookies.Delete = function ( name, path, domain ) {
    document.cookie = name + "=" +
        ( ( path ) ? ";path=" + path : "") +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
wbdUtils.themes = {};
wbdUtils.themes.change = function(theme){
    wbdUtils.cookies.Set('chgcss','global_'+theme,31);
    wbdUtils.themes.load('global_'+theme);
}
wbdUtils.themes.load = function(theme){
    if(!theme){
        theme = wbdUtils.cookies.Get('chgcss');
        if(!theme || theme=='') theme = 'global_'+'classic';
    }
    var css = urlPrefix + '/includes/'+theme+'.css';
        wbdUtils.ajax.Get(css,null,function(resp){
        document.getElementById('lnkCss').href = css+"?280709";
    });
}
wbdUtils.portals = {};
wbdUtils.portals.loadDefault=function(){
    if(window.location.hostname == 'www.webdunia.com' || window.location.hostname == 'webdunia.com'){
        var lang = wbdUtils.cookies.Get('defaultLanguage');
        if(lang && lang !=''){
            window.location.href = "http://" + lang +".webdunia.com"
        }
    }
}
wbdUtils.portals.setDefault=function(lang){
    if(window.location.hostname == 'www.webdunia.com' || window.location.hostname == 'webdunia.com'){
        wbdUtils.cookies.Set('defaultLanguage',lang,31);
    }
    return true;
}


// Common JavaScript Document for WD new layout 2008 - GR@Creative
function hideShowTabDiv(x, id, name, source){
	var a = "tab"+id+"Div";
	var b = "Btn"+id;
	var objDv = document.getElementById('tabDisplay');
	document.getElementById('Btn1').className = "wdp_wBtn wdp_closedTabBtn";
	document.getElementById('Btn2').className = "wdp_wBtn wdp_closedTabBtn";
	document.getElementById('Btn3').className = "wdp_wBtn wdp_closedTabBtn";
	document.getElementById('Btn4').className = "wdp_wBtn wdp_closedTabBtn";
	document.getElementById(b).className = "wdp_wBtn";
	
	if(x == 1){
		document.getElementById('mail_row1').style.display="none";
		document.getElementById('mail_row2').style.display="block";
		document.getElementById('mail_row2_2').style.display="block";
		document.getElementById('mail_row1_1').style.display="none";
		document.getElementById('tabDiv2').className="";
		document.getElementById('tabDiv1').className="wdp_closedTabBtn";
	}
	if(x == 2){
		document.getElementById('mail_row1').style.display="block";
		document.getElementById('mail_row2_2').style.display="none";
		document.getElementById('mail_row1_1').style.display="block";
		document.getElementById('mail_row2').style.display="none";
		document.getElementById('tabDiv1').className="";
		document.getElementById('tabDiv2').className="wdp_closedTabBtn";
	}
	objDv.style.display="block";
	var tmpheight=objDv.offsetHeight-(document.all?12:0);
    var topmargin = tmpheight/2-14;
    objDv.innerHTML = wbdUtils.data.template.TabLoadingData.replace("[HEIGHT]",tmpheight).replace("[TOPMARGIN]",topmargin);

	
    var key = source.replace(/[:\/\.\?\&\=]/ig,"_");
    var data = wbdUtils.data.cache.get(key);
    if(data && data.length>0){
        objDv.innerHTML = data;
    } else {
	    wbdUtils.ajax.Get(source,null,function(resp){
	        var data = resp.responseText
            objDv.innerHTML =data;
            wbdUtils.data.cache.add(key,data);
        });
    }	
}
function nw(obj){obj.value="";}
function openWindowCenterScreen(url,name,height,width,scroll)
{
  var wleft = (screen.width - width) / 2;
  var wLinks = (screen.height - height) / 2;
  var win = window.open(url,name,
                            'width=' + width + ', height=' + height + ', ' +
                            'left=' + wleft + ', Links=' + wLinks + ', ' +
                            'location=no, menubar=no, ' + 'scrollbars=' + (scroll?'yes':'no')+','+
                            'status=no, toolbar=no, resizable=no');
  
  win.focus();    
  
  
//  window.open(url,name,'width=' + width + ', height=' + height + ',' +'location=no, menubar=no');
}
function ChkValue() {
    if ((document.getElementById("user_login").value == "") || (document.getElementById("user_pwd").value == "")){
        alert ("User Name or password can't be blank");
        return false;
    } 
    else
        return true;
}
var bU=false,bP=false
function clearText(obj) {
    switch(obj.name){
        case 'user_login':
            if(!bU){
                obj.value='';
                bU=true;
            }
            break;
        case 'user_pwd':
            if(!bP){
                obj.value='';
                bP=true;
            }
            break;
    }
}
function  ShowFeedBack()
{
	var object = document.getElementById("tAH");    
    var articleTitle;
    if(object!=null)    
    {
        //articleTitle = document.getElementById("tAH").innerText;
        articleTitle = object.innerHTML;
       
    }
    
    else
     {
        object = document.getElementById("printdiv");
        if(object!=null)
        {
          var tmp = object.getElementsByTagName("td");
         
            for(var i=0;i<tmp.length;i++)
            {
                if(tmp[i].className == "articleHeading")
                {
                    articleTitle = tmp[i].innerHTML;
                
                    break;
                 }
             }
        }
        else
        {
         articleTitle = "";
        }
     }
//    if(window.location.href=='http://www.webdunia.com/landing.htm#')
//	    openWindowCenterScreen("http://hindi.webdunia.com/portalcms/feedback/feedback.aspx?url=" + escape(window.location.href) + "&articletitle=" +escape(articleTitle),'FeedBack',460,480);
//	else
	   openWindowCenterScreen("http://feedback.webdunia.com/"+gappName+"/default.aspx?url=" + escape(window.location.href) + "&articletitle=" +escape(articleTitle),'FeedBack',460,480);	
}

//send to Friend Funtion
function  ShowSendToFriend()
{  
    var object = document.getElementById("tAH");    
    var articleTitle="";
    if(object!=null)    
    {
        //articleTitle = object.innerHTML;
        if(object.childNodes.length>0){
            var tmpobjs = GetElementsByClassName(object,'kreative','span',true);
            if(tmpobjs.length>0)
               articleTitle = tmpobjs[0].innerHTML;                
        } else {articleTitle = object.innerHTML;}
                   

    }
    
    else
     {
        object = document.getElementById("printdiv");
        if(object!=null)
        {
          var tmp = object.getElementsByTagName("td");
         
            for(var i=0;i<tmp.length;i++)
            {
                if(tmp[i].className == "articleHeading")
                {
                    if(tmp[i].childNodes.length>0){
                        var tmpobjs = GetElementsByClassName(tmp[i],'kreative','span',true);
                        if(tmpobjs.length>0)
                            articleTitle = tmpobjs[0].innerHTML;                
                    } else {articleTitle = tmp[i].innerHTML;}
                    break;
                 }
             }
        }
        else
        {
         articleTitle = "";
        }
     }
        
//	    if(window.location.hostname=='www.webdunia.com' || window.location.hostname=='webdunia.com')
//            openWindowCenterScreen("http://hindi.webdunia.com/PortalCMS/sendtofriend/sendtofriendmail.aspx?url=" + escape(window.location.href) + "&title=" +escape(articleTitle),"SendToFriend",560,480)
//        else
           openWindowCenterScreen("http://in.webdunia.com/" + gappName + "/portalcms/SendToFriend/SendToFriendmail.aspx?url=" + escape(window.location.href) + "&title=" +escape(articleTitle),"SendToFriend",560,480)
}

function  ShowVideos(query,wHeight, wWidth)
{
    //var url = "/Videos/ShowVideo.aspx?"+query;
    var url = "";
//    if(window.location.hostname=='www.webdunia.com')
//        url = "http://hindi.webdunia.com/videos/webduniaPlayer.html?"+query;
//    else
        url = urlPrefix + "/videos/webduniaPlayer.html?"+query;
    var wName = "ShowVideo"
	openWindowCenterScreen(url,wName,350,750);
//	postWindowsData(url,wName,query)
}

function openPoll(obj, catid, pollid)
{
    var tmp = wbdUtils.DOM.getParentByName(obj,'dvPoll','div');
    var targ =  tmp.getElementsByTagName("input");
    for(var i=0;i<targ.length;i++)
    {
        var prnt = targ[i];
        var objName = prnt.attributes?prnt.attributes.getNamedItem("name")?prnt.attributes.getNamedItem("name").value:'':'';
        if(objName == "poll" &&  targ[i].checked)
        {
            var answer=targ[i].value;
       }
    }
    var page = 0;
//    if(window.location.hostname=='www.webdunia.com')
//        openWindowCenterScreen("http://hindi.webdunia.com/Poll/PollResult.aspx?result=" +answer + "&pollid=" +pollid + "&page=" +page , 'PollResult',480,500);
//    else
        openWindowCenterScreen("http://in.webdunia.com/Malayalam/Poll/PollResult.aspx?result=" +answer + "&pollid=" +pollid + "&page=" +page , 'PollResult',480,500);
}

function popRashi(objrashiid)
{
    var rashiId = objrashiid;
    var rashiMode = document.getElementById("selrashimode").value;
//    if(window.location.hostname=='www.webdunia.com')
//        window.location.href="http://hindi.webdunia.com/astrology/predictions/predictions.aspx?rashiId=" +rashiId + "&rashiMode=" +rashiMode + "#" + rashiId;
//    else  
        window.location.href=urlPrefix + "/astrology/predictions/predictions.aspx?rashiId=" +rashiId + "&rashiMode=" +rashiMode + "#" + rashiId;
}

/*function OpenGallery(ImageId, GalleryId, Index, Link)
{
//    if(window.location.hostname=='www.webdunia.com')
//        openWindowCenterScreen("http://hindi.webdunia.com/PhotoGallery/PhotoGalleryImageWindow.aspx?IId=" + ImageId  + "&GId=" + GalleryId + "&Idx=" + Index + "&Link=" + Link,"gallery",700,580)
//   else     
        openWindowCenterScreen(urlPrefix + "/PhotoGallery/PhotoGalleryImageWindow.aspx?IId=" + ImageId  + "&GId=" + GalleryId + "&Idx=" + Index + "&Link=" + Link,"gallery",700,580)
}*/
function OpenGallery(ImageId, GalleryId, Index, Link)
{
//    if(window.location.hostname=='www.webdunia.com')
//        openWindowCenterScreen("http://hindi.webdunia.com/PhotoGallery/PhotoGalleryImageWindow.aspx?IId=" + ImageId  + "&GId=" + GalleryId + "&Idx=" + Index + "&Link=" + Link,"gallery",700,580)
//   else     
        //openWindowCenterScreen(urlPrefix + "/PhotoGallery/PhotoGalleryImageWindow.aspx?IId=" + ImageId  + "&GId=" + GalleryId + "&Idx=" + Index + "&Link=" + Link,"gallery",700,580)
        window.open("http://PhotoGallery.webdunia.com/"+gappName+"/inner.aspx?GalleryId=" + GalleryId + "&ShowImageId=" + ImageId);
}
function OpenPhotoGallery(Link){
    window.open(Link);
}

function channelHideShow(a,b){
            var x = a;
            var objDiv = document.getElementById(x)
            var objUp = document.getElementById(a+'Up')
            var objDo = document.getElementById(a+'Down')
            if(b==1){
                objDiv.style.display = "block";
                objUp.style.display = "block";
                objDo.style.display = "none";
            }
            if(b==0){
                objDiv.style.display = "none";
                objUp.style.display = "none";
                objDo.style.display = "block";
            }
        }

function showVideo(url){
    document.getElementById('wdp_video_div').style.display = "block";
    document.getElementById('video_div').style.display = "none";
    document.getElementById('wdp_video_div').innerHTML = wbdUtils.data.template.TabVideoData.replace(/\[VIDEOURL\]/ig,url)
}
function closeVideo(){
    document.getElementById('wdp_video_div').style.display = "none";
    document.getElementById('video_div').style.display = "block";
}
function videoClicked(){document.getElementById('main_news_div').style.display="none";document.getElementById('video_div').style.display="block";document.getElementById('1_tab1').className="wdp_tab";document.getElementById('1_tab2').className="wdp_selectedTab";document.getElementById('1_curve2').className="wdp_tabCurveLast new";document.getElementById('1_curve1').className="wdp_tabCurve";}function mainNewsClicked(){document.getElementById('main_news_div').style.display="block";document.getElementById('video_div').style.display="none";document.getElementById('1_tab1').className="wdp_selectedTab";document.getElementById('1_tab2').className="wdp_tab";document.getElementById('1_curve1').className="wdp_selectedTabCurve";document.getElementById('1_curve2').className="wdp_tabCurveLast";document.getElementById('wdp_video_div').style.display = "none";}function showColorOption(){document.getElementById('selectColorDiv').style.display = "block";}function closeColorOption(){document.getElementById('selectColorDiv').style.display = "none";}function changeColorClass(id){document.getElementById('color1').className = "wdp_color1";document.getElementById('color2').className = "wdp_color2";document.getElementById('color3').className = "wdp_color3";document.getElementById('color4').className = "wdp_color4";document.getElementById('color5').className = "wdp_color5";	document.getElementById('color'+id).className = "wdp_color"+id+"_s";}function startCounter(){t = setTimeout("closeColorOption();", 5000);}function showDiv(id){document.getElementById(id).style.display = "block";}function hideDiv(id){document.getElementById(id).style.display = "none";}
function closeTab(id){
document.getElementById('Btn1').className = "wdp_wBtn wdp_closedTabBtn";
document.getElementById('Btn2').className = "wdp_wBtn wdp_closedTabBtn";	
document.getElementById('Btn3').className = "wdp_wBtn wdp_closedTabBtn";
document.getElementById('Btn4').className = "wdp_wBtn wdp_closedTabBtn";
document.getElementById('tabDiv1').className="";
document.getElementById('tabDiv2').className="";
document.getElementById('tabDisplay').style.display="none";
}
function showRashi(wdp_rashi){window.location.href = "http://astrology.webdunia.com/"+language+"/predictions/predictions.aspx?rashiId=" +wdp_rashi + "&rashiMode=1" + "#" + wdp_rashi;}
function getActiveSwf(){
    var objects = document.getElementsByTagName("object");
    for (var i = 0; i < objects.length; i++){
        objects[i].outerHTML = objects[i].outerHTML;
    }
}
function setFlashMaxA(){
	document.getElementById('flashid').style.width = '405px';
	document.getElementById('flashid').style.height = '300px';
	document.getElementById('videoDiv').style.height = '410px';
}

function setFlashRestoreA(){
	//alert("setFlashMa");
	document.getElementById('flashid').style.width = '150px';
	document.getElementById('flashid').style.height = '150px';
	document.getElementById('videoDiv').style.height = '150px';
}
function OpenMainHPVideo(obj,vpath)
{
obj.parentNode.innerHTML='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="100%" height="100%" id="fp" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="/img/cm/video/TabVideoPlayer.swf?filepath=' + vpath + '&amp;expand=1" /><param name="quality" value="high" /><param name="devicefont" value="true" /><param name="bgcolor" value="#000000" /><param name="FlashVars" value="allowResize=true" /><embed src="/img/cm/video/TabVideoPlayer.swf?filepath=' + vpath + '&amp;expand=1" quality="high" devicefont="true" bgcolor="#000000" width="100%" height="100%" name="mediaplayer" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" /></object>'
}

function openBarChart(){
	  	var str = window.location.href;
        var rg = new RegExp('http://(.*?)\\.webdunia\\.com');
        rg.ignoreCase = true;
        rg.multiline = true;
        if (rg.test(str)) {
            var m = rg.exec(str);
            window.location.href = "http://in.webdunia.com/"+m[1]+"/election/ElectionResults2009Map.aspx";
        }
}
