// JavaScript Document
function handleHttpResponse() {	
if (http.readyState != 4) {
//document.body.style.cursor = "wait";
//document.getElementById(shows).innerHTML = "Loading..";
}
if (http.readyState == 4) {
		if(http.status==200) {
		var results=http.responseText;
		document.getElementById(shows).innerHTML = results;
	//	document.body.style.cursor = "default";
		}
	}
}
		
function ajaxRequest(id,show,url){

	shows = show;
	http.open("get", url+".php?"+id, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
	
}

function rateit(key,dis){
	ajaxRequest('id='+key,'disply_'+dis,'..//rate_it');
}
		
function getHTTPObject() {
var xmlhttp; 
	if(window.XMLHttpRequest){
	xmlhttp = new XMLHttpRequest();
	}
  else if (window.ActiveXObject){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	if (!xmlhttp){
	xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
}
  return xmlhttp;
}

var http = getHTTPObject(); // We create the HTTP Object



 function CreateBookmarkLink(title,url) {

	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; }
 }

function Bookmark(title,url) {
  document.write('<a href = "javascript:;" onclick="CreateBookmarkLink(\''+title+'\',\''+url+'\')");">Bookmark Page</a>'); 
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  //if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function setmsg(id,msg){
	if(document.getElementById('msg_'+id)){
		document.getElementById('msg_'+id).style.display = 'block';
		document.getElementById('msg_'+id).innerHTML = msg;
	}
}

function resetmsg(id){
	if(document.getElementById('msg_'+id)){
		document.getElementById('msg_'+id).style.display = 'none';
	}
}

function MM_validateForm() { //v4.0

  var i,p,q,nm,test,num,min,max,errors='',vals,args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
  vals = val;
    if (val) { nm=val.title; nid = val.id; resetmsg(nid); if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)){setmsg('- '+nm+' must contain an e-mail address.'); errors+='- '+nm+' must contain an e-mail address.\n'};
      } else if (test.indexOf('isChk')!=-1) { 
        if (vals.checked==false) setmsg(nid,'- '+nm+' is required.');
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R'){ setmsg(nid,'- '+nm+' is required.'); errors += '- '+nm+' is required.\n'; }}
  } //if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function clearValue(field) {
   if(field.value.indexOf("Enter Your Message Here") != -1){
      field.value = '';
      field.style.color = '#333333';
   }
} 

function Toggle(id,id2){
ids = document.getElementById(id).style.display;
	if(ids=='none'){
		document.getElementById(id).style.display='block';
	}else{
		document.getElementById(id).style.display='none';
		if(id2!=''){
			document.getElementById(id2).value = '';
		}
	}
}



function px(i,maxs){ 

for(a=1;a<=maxs;a++){
	document.getElementById('pic'+a).style.display='none';
	document.getElementById('thumbs_'+a).className='';
}
	document.getElementById('pic'+i).style.display='block';
	document.getElementById('thumbs_'+i).className='selected';
}


function over(control){
if(control.phase == 0){
control.src = "images/star_hover.gif";
}
control.style.cursor = 'pointer'
}
function defaults(control){
if(control.phase == 0){
control.src = "images/star_blank.gif";
}
control.style.cursor = 'default';
}

function ratingclick(id,pointer){
//alert(pointer);

for(a=1;a<=5;a++){
	ids = 'star_'+id+'_'+a;
	document.getElementById('rate_'+id).value = pointer;
	if(a<=pointer){
			document.getElementById(ids).src="images/star_filled.gif";
			document.getElementById(ids).phase="1";
		}else{
			document.getElementById(ids).src="images/star_blank.gif";
			document.getElementById(ids).phase="0";
		}
	}
}

function shownba(control){
	control.className='selected';
	document.getElementById('nhl_score').style.display='none';
	document.getElementById('nfl_score').style.display='none';
	
	document.getElementById('nfl_button').className='';
	document.getElementById('nhl_button').className='';
	document.getElementById('nba_score').style.display='';
	//ajaxRequest(21,'nba_score','get_nba_scores');
}
function shownfl(control){
	control.className='selected';
	document.getElementById('nhl_score').style.display='none';
	document.getElementById('nba_score').style.display='none';
	
	document.getElementById('nba_button').className='';
	document.getElementById('nhl_button').className='';
	document.getElementById('nfl_score').style.display='';
	//ajaxRequest(22,'nba_score','get_nba_scores');
}
function shownhl(control){
	control.className='selected';
	document.getElementById('nfl_score').style.display='none';
	document.getElementById('nba_score').style.display='none';
	
	document.getElementById('nba_button').className='';
	document.getElementById('nfl_button').className='';
	document.getElementById('nhl_score').style.display='';
	//ajaxRequest(23,'nba_score','get_nba_scores');
}

$(document).ready(function(){
if($('.c')){
						   $('.c').initTogglePane(); 
}
}); //  $(document).ready

// http://roshanbh.com.np
	$(document).ready(function() {
	$(window).scroll(function() {
		if($('.hover-f')){
			$('.hover-f').animate({bottom:$(window).scrollBottom()+"px" },{queue: false, duration: 350}); 
		}
	});
	$('#close_message').click(function() {
	$('.hover-f').animate({right:"-=25px", opacity:0 }, "fast"); });
	$(window).scroll(function()	{
  	$('.hover-r').animate({bottom:$(window).scrollBottom()+"px" },{queue: false, duration: 350}); });
	$('#close_feedback').click(function() {
	$('.hover-r').animate({right:"-=25px", opacity:0 }, "fast"); });
});
	
	$(document).ready(function(){
	$("#nav-one li").hover(
		function(){ $("ul", this).fadeIn("fast"); }, 
		function() { } 
	);
  	if (document.all) {
		$("#nav-one li").hoverClass ("sfHover");
	}
});
		$.fn.hoverClass = function(c) {
		return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
};	  

function addOption_all_list(selectbox){

}

function addOption(selectbox,text,value,store )
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		if(selectbox.options[i].value==value){
			alert('Already Exist');
			return;
		}
	}
	
	var optn = document.createElement("OPTION");
	optn.text = text;
	optn.value = value;
	selectbox.options.add(optn);
	store.value = store.value+','+value
}

function removeOption(listbox,i)
{
	listbox.remove(i);
}

function addOption_list(name,next,values){
for(i=document.getElementById(name).options.length-1;i>=0;i--)	{
var Category=document.getElementById(name);
if(Category[i].selected){
addOption(document.getElementById(next), Category[i].text, Category[i].value,document.getElementById(values));
//removeOption(document.getElementById(name),i);
}
}
}


function move_all_Option(selectbox){
for(i=document.drop_list.Category.options.length-1;i>=0;i--)	{
var Category=document.drop_list.Category;
addOption(document.drop_list.SubCat, document.drop_list.Category[i].value, document.drop_list.Category[i].value);

}
removeAllOptions(document.drop_list.Category);
}



function removeAllOptions(selectbox)
{
	var i;
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		//selectbox.options.remove(i);
		selectbox.remove(i);
	}
}
function removeselection(selectbox_val,value,store_val,mainteams){
	var i;
	var selectbox;
	var store ;
	if(mainteams!=''){
		mainstore = document.getElementById(mainteams);
	}
	var value = document.getElementById(value).value;
	selectbox = document.getElementById(selectbox_val);
	store = document.getElementById(store_val);
	for(i=selectbox.options.length-1;i>=0;i--)
	{
		if(selectbox.options[i].value==value){
			selectbox.remove(i);		
			newdata = store.value.replace(','+value, "");
			store.value = newdata;
			if(mainteams!=''){
			newdata = mainstore.value.replace(','+value, "");
			mainstore.value = newdata;					
			}
		}
	}
}

function rate(preface,id,val){
	id = 'id='+id+'&preface='+preface+'&rate='+val;
	ajaxRequest(id,'rateResult','countRating');
}

function active(control){
document.getElementById('tab1').style.display = 'none';
document.getElementById(control).className = '';
document.getElementById('tab2').style.display = 'none';
document.getElementById(control).className = '';
document.getElementById('tab3').style.display = 'none';
document.getElementById(control).className = '';

document.getElementById(control).style.display = 'block';
document.getElementById(control).className = 'active';

}
function toggleview(cont){
	var control = document.getElementById(cont);
	if(control.style.display==''){
		control.style.display='none';
	}else{
		control.style.display='';
	}
}