// Splintered striper 1.3// reworking of Zebra Tables and similar methods which works not only for tables and even/odd rows,// but as a general DOM means of assigning any number of classes to children of a parent element.// Patrick H. Lauke aka redux / www.splintered.co.uk// Distributed under the Creative Commons Attribution-ShareAlike license - http://creativecommons.org/licenses/by-sa/2.0//* * Summary:      Core experiment function that applies any number of classes to all child elements *               contained in all occurences of a parent element (either with or without a specific class) * Parameters:   parentElementTag - parent tag name *               parentElementClass - class assigned to the parent; if null, all parentElementTag elements will be affected *               childElementTag -  tag name of the child elements to apply the styles to *               styleClasses - comma separated list of any number of style classes (using 2 classes gives the classic "zebra" effect) * Return:       none */function striper(parentElementTag, parentElementClass, childElementTag, styleClasses){	var i=0,currentParent,currentChild;	// capability and sanity check	if ((document.getElementsByTagName)&&(parentElementTag)&&(childElementTag)&&(styleClasses)) {		// turn the comma separate list of classes into an array		var styles = styleClasses.split(',');		// get an array of all parent tags		var parentItems = document.getElementsByTagName(parentElementTag);		// loop through all parent elements		while (currentParent = parentItems[i++]) {			// if parentElementClass was null, or if the current parent's class matches the specified class			if ((parentElementClass == null)||(currentParent.className == parentElementClass)) {				var j=0,k=0;				// get all child elements in the current parent element				var childItems = currentParent.getElementsByTagName(childElementTag);				// loop through all child elements				while (currentChild = childItems[j++]) {					// based on the current element and the number of styles in the array, work out which class to apply					k = (j+(styles.length-1)) % styles.length;					// add the class to the child element - if any other classes were already present, they're kept intact					currentChild.className = currentChild.className+" "+styles[k];				}			}		}	}}/**   Functions added by Athar*/ function forceClick(e, elemId) {
    var elem = document.getElementById(elemId);
    var evt = (e) ? e : window.event;
    var intKey = (evt.which) ? evt.which : evt.keyCode;

    if(intKey == 13) {
        elem.click();
        return false;
    }

    return true;
    }        /*********************************/
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();

function setSearchOverlay()
{    
    var _width = 750;
    
    var _height = screen.availHeight;	
    
    if (BrowserDetect.browser == 'Explorer' && BrowserDetect.version <=6 ) 
    {     
        //alert(screen.availHeight);       
        
        /*
        if ($get('weatheractivity1_PanelSearch1'))
        {
            if (screen.availWidth >= 1000)
			    _width = 850;
	        	        
            $get('weatheractivity1_PanelSearch1').style.width = _width + 'px';
            
            //$get('weatheractivity1_PanelSearch1').style.height= _height + 'px';
        }
        */

    }
    
    
 }                     //    $addHandler($get("lnkVMap"), 'click', showModalVMapPopupViaClient);    /* Used in WeatherActivity Web User Control to animate forecast browser modal window */        // Move an element directly on top of another element (and optionally
    // make it the same size)
    function Cover(bottom, top, ignoreSize) {
        var location = Sys.UI.DomElement.getLocation(bottom);
        top.style.position = 'absolute';
        top.style.top = '-110px';
        top.style.left = '10px';
        if (!ignoreSize) {
            top.style.height = bottom.offsetHeight + 'px';
            top.style.width = bottom.offsetWidth + 'px';
       }
    }

    function Resize(bottom) {
        
        bottom.style.width=screen.availWidth - 130 ;
        
        bottom.style.height=screen.availHeight - 200;
        
    }               function setAjaxLoaderOff() {        var updateProgressDiv = $get('updateProgressDivForecastData'); 
        
         if (updateProgressDiv!=null)        
            updateProgressDiv.style.display = 'none';
           }           function onUpdatingUpdatePanel(updateProgressDiv,gridView) {
        // get the update progress div
        //var updateProgressDiv = $get('updateProgressDivForecastData'); 
        // make it visible
        updateProgressDiv.style.display = '';

        //  get the gridview element        
        //var gridView = $get('<%= this.UpdatePanelForecastData.ClientID %>');
        
        // get the bounds of both the gridview and the progress div
        var gridViewBounds = Sys.UI.DomElement.getBounds(gridView);
        var updateProgressDivBounds = Sys.UI.DomElement.getBounds(updateProgressDiv);
       
        //    do the math to figure out where to position the element (the center of the gridview)
        var x = gridViewBounds.x + Math.round(gridViewBounds.width / 2) - Math.round(updateProgressDivBounds.width / 2);
        var y = gridViewBounds.y + Math.round(gridViewBounds.height / 10);
        
        //    set the progress element to this position
        Sys.UI.DomElement.setLocation (updateProgressDiv, x, y);        
    }

    function onUpdatedUpdatePanel(updateProgressDiv) {
        // get the update progress div
        //var updateProgressDiv = $get('updateProgressDivForecastData'); 
        // make it invisible
        if (updateProgressDiv!=null)
            updateProgressDiv.style.display = 'none';
        
       
    }    
    
    
    function setWeatherActivityID(id) {
    
        var v=document.getElementById('weatheractivity1_activity_id');
        
        v.value=id;        
    }
        function showModalPopupOnPageLoad()
     {
        var modalPopupBehavior = $find('programmaticModalGaleWarningPopupBehavior');
        
        if (modalPopupBehavior!=null)
            modalPopupBehavior.show();
        
     }   
    
function showLoaderOnMapShape() {
    var sh=null;
    
    if ($get('ajax_loader_vmap'))
    {
        sh = $get('ajax_loader_vmap');    
        
        sh.style.display ='';    
    }
    else
        alert($get('ajax_loader_vmap'));
    
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}



function eraseCookie(name) {
	createCookie(name,"",-1);
}
