// <blogde> added by dl
function F() {
	return document.forms[0];
}
// </blogde>

// <blogde> added by fw

//Default browsercheck

function checkBrowser(){
	this.ver=navigator.appVersion
	this.dom=document.getElementById?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
	return this
}

//With nested layers for netscape, this function hides the layer if it's visible and visa versa
function showHide(div,nest){
	bw=new checkBrowser()
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	//obj = document.getElementById(div).style;

	//if(obj.visibility=='visible' || obj.visibility=='show') obj.visibility='hidden'
	//else obj.visibility='visible'

	if(obj.display=='block' || obj.display=='block') obj.display='none'
	else obj.display='block'
}
//Shows the div
function show(div,nest){
	bw=new checkBrowser()
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='visible'
}

function showBlock(div,nest){
	bw=new checkBrowser()
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.display='block'
}

//Hides the div
function hideBlock(div,nest){
	bw=new checkBrowser()
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.display='none'
}

function hide(div,nest){
	bw=new checkBrowser()
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.visibility='hidden'
}

function switchSelection(value)
{
	if (value=='friends') {
		showBlock('friends_div');
	} else {
		hideBlock('friends_div');
	}
}

function checkAll(grp_id, checked) {
	setStatusFriends();
	grpDiv = document.getElementById(grp_id);
	elements = grpDiv.getElementsByTagName('input');
	for (i=0; i < elements.length; i++) {
		elements[i].checked=checked;
	}
	checkGroups();
}

function showCurrency(cur_id,max)
{
	for (i=1; i < max+1; i++)
	{
		grpDiv = document.getElementById('currency_' + i);
			grpDiv.style.display='none';
	}
	elemDiv = document.getElementById('currency_' + cur_id);
	elemDiv.style.display='block';
}

function showOnly(cur_id,max)
{
	for (i=1; i < max+1; i++)
	{
		grpDiv = document.getElementById('itemcolor-' + i);
			grpDiv.style.display='none';
	}
	for (i=1; i < max+1; i++)
	{
		grpDiv = document.getElementById('itemcolor-' + i + '-enlarge');
			grpDiv.style.display='none';
	}
	elemDiv = document.getElementById(cur_id);
	elemDiv.style.display='block';
	elemDiv = document.getElementById(cur_id+'-enlarge');
	elemDiv.style.display='block';
}

function HideAllColors(max)
{
	for (i=1; i < max+1; i++)
	{
		grpDiv = document.getElementById('itemcolor-' + i);
			grpDiv.style.display='none';
	}
	for (i=1; i < max+1; i++)
	{
		grpDiv = document.getElementById('itemcolor-' + i + '-enlarge');
			grpDiv.style.display='none';
	}
}

function checkAll2(grp_id, checked) {
	grpDiv = document.getElementById(grp_id);
	elements = grpDiv.getElementsByTagName('input');
	for (i=0; i < elements.length; i++) {
		elements[i].checked=checked;
	}
	checkGroups();
}

// <blogde> added by ms
function checkGroup(grp_id) {
	var grp = document.getElementById('fgrp_' + grp_id);
	var elements = grp.getElementsByTagName('input');
	var i=0;
	var count = 0;
	if (elements) {
		for (i=0; i<elements.length; i++) {
			if (elements[i].checked) {
				count++;
			}
		}
		if (count == elements.length) {
			document.getElementById('chk_' + grp_id).checked = true;
		} else {
			document.getElementById('chk_' + grp_id).checked = false;
		}
		return true;
	}
	else return false;
}

function checkGroups() {
	var i=0;
	var grps = document.getElementById('fgrps');
	var elements = grps.getElementsByTagName('div');
	for (i=0; i<elements.length; i++) {
		id = elements[i].id.split('_');
		checkGroup(id[1]);
	}
}

function activateAll() {
	var bodylist = document.getElementById('fgrps');
	var elements = bodylist.getElementsByTagName('input');
	if (elements) {
		for (i=0; i < elements.length; i++) {
			elements[i].checked = 1;
		}
	}
}

function deactivateAll() {
	var bodylist = document.getElementById('fgrps');
	var elements = bodylist.getElementsByTagName('input');
	if (elements) {
		for (i=0; i < elements.length; i++) {
			elements[i].checked = 0;
		}
	}
}
// </blogde>


function openWindow(url)
{
	newWindow = window.open(url,'window','width=574,height=380,left=50,top=50,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	newWindow.focus();
}


function openWindowSized(url, myTitle, myWidth, myHeight) {
	newWindow = window.open(url, myTitle, 'width = '+myWidth+', height = '+myHeight+',left=50,top=50,toolbar=yes,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	newWindow.focus();
}

function bdOpenWindow(url)
{
	newWindow = window.open(url,'window','width=574,height=380,left=50,top=50,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	newWindow.focus();
}
// </blogde>

//<blogde> coded by jasvir
function OpenIcon(url) {
	var Iconwindow;
	Iconwindow=window.open(url,"Choose Icon",'height=300,width=200,left=100,top=300,screenX=100,screenY=300');
	Iconwindow.focus();

}

function CloseIcon()
{
  self.close();
}

// function used to change the icon in the document directly
function changeIcon()
{
//  opener.location.reload(true);
  Iconwindow=window.open("http://www.yahoo.com","Choose Icon",'height=300,width=200,left=100,top=300,screenX=100,screenY=300');
  doc = opener.document.getElementById('icons');
  elements = doc.getElementsByTagName('img');
  if (elements.length>0) {
    elements[0].src = '/blogde/www/jasvir/img/icons/icon_friend_1.gif';
  }
}
//</blogde> coded by jasvir

/*
 * javascript open_preview()
 * opens preview window
 *
 * @author Dami Falasinnu
 * @param form
 */
function open_preview(form)
{
	preview_window = window.open( '','','width=574,height=380,left=50,top=50,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes' );
	text = form.comment.value.replace(/\n/g, '<br />');
	preview_window.document.write(text);
	preview_window.document.write('<p><a href="javascript:window.close()">Close Window</a></p>');
	preview_window.focus();
}

function bdOpenWindowTrackback(url, form)
{
	param_tb = form.tb_id.value;
	param_code = form.code.value;
	url_new = url+'?tb_id='+param_tb+'&code='+param_code;
	newWindow = window.open(url_new,'window','width=500,height=300,left=50,top=50,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');
	newWindow.focus();
}


function setFontBold(div,nest){
	bw=new checkBrowser();
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.fontWeight="bold";
}

function setFontNormal(div,nest){
	bw=new checkBrowser();
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0;
	obj.fontWeight="normal";
}

function textSelectToggleByName(link, targetname, snip)
{
	target = document.getElementsByName(targetname)[0];
	textSelectToggle(link, target, snip);
}

function textSelectToggle(link, target, snip)
{
	var string = target.value;
	var elements = string.split(',');
	var found = false;
	for(i=0;i<elements.length;i++)
	{
		if (elements[i] == '')
		{
			elements.splice(i,1)
		}
		else if (elements[i] == snip)
		{
			elements.splice(i,1)
			found = true;
			break;
		}
	}

	if (found == false)
	{
		elements.push(snip);
		link.style.fontSize = '14px';
		link.style.fontWeight = 'bold';
	}
	else
	{
		link.style.fontSize = '12px';
		link.style.fontWeight = 'normal';
	}

	elements.sort();
	target.value = elements.join(',');
}
// </blogde>


/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + 560000 : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" +
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}

function cssClassActions(a,o,c1,c2)
{
  switch (a){
    case 'swap': // replaces class c1 with class c2 in object o
      o.className=!cssClassActions('check',o,c1)? o.className.replace(c2,c1): o.className.replace(c1,c2);
    break;
    case 'add': // adds class c1 to the object o
      if(!cssClassActions('check',o,c1)){o.className+=o.className?' '+c1:c1;}
    break;
    case 'remove': // removes class c1 from the object o
      var rep=o.className.match(' '+c1)?' '+c1:c1;
      o.className=o.className.replace(rep,'');
    break;
    case 'check': // test if class c1 is already applied to object o and returns true or false
      return new RegExp('\\b'+c1+'\\b').test(o.className)
    break;
  }
}

/**
 * Rico
 * http://openrico.org/rico/downloads.page
 *
 */
document.getElementsByTagAndClassName = function(tagName, className) {
  if ( tagName == null )
     tagName = '*';

  var children = document.getElementsByTagName(tagName) || document.all;
  var elements = new Array();

  if ( className == null )
    return children;

  for (var i = 0; i < children.length; i++) {
    var child = children[i];
    var classNames = child.className.split(' ');
    for (var j = 0; j < classNames.length; j++) {
      if (classNames[j] == className) {
        elements.push(child);
        break;
      }
    }
  }

  return elements;
}

function open_window(href, width, height, name) {
 window_left = (screen.width / 2) - (width / 2);
 window_top = (screen.height / 2) - (height / 2);
 new_window = window.open(href, name, 'width=' + width + ',height=' + height + ',left=' + window_left + ',top=' + window_top + ',scrollbars=yes,resizable=yes,menubar=no,toolbar=no,status=no');
 new_window.focus();
}

function deletestuff() {
  var verify = window.confirm("Do you really want to delete?");
  return (verify);
}

function changestuff() {
  var verify = window.confirm("Do you really want to change this shizzle?");
  return (verify);
}
