// JavaScript Document

function bookmarkUs()
{
  if (document.all) {
    window.external.AddFavorite ("http://www.andhraguide.com/", "Diksuchi-The navigational guide");
  }
  else {
  var msg = "Press CTRL-D to bookmark us!";
  if(navigator.appName == "Netscape") alert(msg);
  }
}

function snark()
{
  if (top.location != location) {
    top.location.href = document.location.href ;
  }
}

function setPreference()
{
	if (document.preference.newwindow.checked) setNavigationStyle(1);
	else setNavigationStyle(0);
	alert("Your preference has been saved");
}

function getCookieExpireDate(noDays){
  var today = new Date()
  var expr = new Date(today.getTime()+noDays*24*60*60*1000)
  return  expr.toGMTString()
  }

function setCookie (name, value, noOfDays, path, domain, secure) 
{
  document.cookie = name + "=" + escape (value) +
    ((noOfDays) ? "; expires=" + getCookieExpireDate(noOfDays) : "") +
    ((path) ? "; path=" + path : "/") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

function getCookie(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));
}

function deleteCookie(name)
{ 
  var cookieValue = getCookie(name);
  if ((cookieValue != null) && (cookieValue != ""))
    {
		var exp = new Date(); 
		exp.setTime(exp.getTime() - 1); 
		document.cookie = name + "=" + "; expires=" + exp.toGMTString();
    }
}

function maximizeWindow(){
	top.window.moveTo(0,0);
	top.window.resizeTo(screen.width,screen.height);
}


var navigationStyle = 0;
var agent_isIE = true;
var agent_isNS = false;
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

doBrowserCheck();
getNavigationStyle();

function checkIt(string)
{
place = detect.indexOf(string) + 1;
thestring = string;
return place;
}

function getBrowserName()
{
if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}
return browser;
}

function doBrowserCheck()
{
var ap = getBrowserName();
agent_isNS = ap.indexOf('Netscape') >= 0;
if (agent_isNS) agent_isIE = false;
}

function getNavigationStyle()
{
   navigationStyle = getCookie("navigationStyle");
   if (navigationStyle == null) navigationStyle = 0;
   else navigationStyle = parseInt(navigationStyle);
   return navigationStyle;
}
     
function openPopWindow(url, name, popw, poph)
{
    x = (640 - popw)/2, y = (480 - poph)/2;

    if (screen) {
        y = (screen.availHeight - poph)/2;
        x = (screen.availWidth - popw)/2;
    }

    window.open(url, name, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + popw + ',height='+ poph +',screenX='+x+',screenY='+y+',top='+y+',left='+x);
}

function openMainLink(link)
{
    var returnValue = true;
    if (navigationStyle == 1) 
    {
	window.open(link.href,"_blank");
	returnValue = false;
    }
    return returnValue;
}

function open_link(link)
{
    var returnValue = true;
    if (navigationStyle == 1) 
    {
	window.open(link.href,"_blank");
	returnValue = false;
    }
    return returnValue;
}

function setNavigationStyle(input)
{
  setCookie("navigationStyle", input, 365, "/", "andhraguide.com");
}