 /*
 | ----------------------------------------------------------------------------------------
 | Site Fuctions
 | ----------------------------------------------------------------------------------------
 */
	 /*topcut menu*/
	function showmenu(m,current,list_id){
		var i=0;
		for(i=0;i<10;i++)
		{
			if($("#"+"h"+i).get(0)){				
				$("#"+"h"+i).css({'visibility' : 'hidden'});				 				
			}
			if($("#l"+i).get(0)){
				$("#l"+i).css({'background' : 'none'});
			}	
		}
		$("#"+list_id).css({'background' : '#ecebe2'});
		$("#l"+current).css({'background' : '#ecebe2'});
		$("#"+m).css({'visibility' : 'visible'});
		$("#"+"h"+current).css({'visibility' : 'visible'});		
	}
	/*topcut menu*/
	function hidemenu(selected){
		for(i=0;i<10;i++)
		{		
			if($("#"+"h"+i).get(0)){				
				$("#"+"h"+i).css({'visibility' : 'hidden'});				 				
			}
			if($("#l"+i).get(0)){
				$("#l"+i).css({'background' : 'none'});
			}	
		}
		$("#"+"h"+selected).css({'visibility' : 'visible'});		
		$("#l"+selected).css({'background' : '#ecebe2'});
	}
	
	function showmenuLi(m,current,id){
		
		//document.getElementById(id).css("color","#fff");
		
		/*
		for(i=1;i<10;i++)
		{		
			if(document.getElementById("h"+i)){	
				document.getElementById("h"+i).style.visibility='hidden';				 				
			}	
		}
		document.getElementById(m).style.visibility='visible';
		document.getElementById("h"+current).style.visibility='visible';		  
		//document.getElementById(m).style.visibility='hidden';
		//document.getElementById(m).parentNode.childNodes[0].style.color = '#575757';
		*/
	}
	
	$.ajaxSetup({
		error:function(x,e){
			//alert("The url you entered is not correct!");			
			if(x.status==0){
			alert('You are offline!!\n Please Check Your Network.');
			}else if(x.status==404){
			alert('Requested URL not found.');
			}else if(x.status==500){
			alert('Internel Server Error.');
			}else if(e=='parsererror'){
			alert('Error.\nParsing JSON Request failed.');
			}else if(e=='timeout'){
			alert('Request Time out.');
			}else {
			alert('Unknow Error.\n'+x.responseText);
			}			
		}
	});	

	$(document).ready(function ()
	{
		/*functions for sliding boxes**************************************************************/
		//To switch directions up/down and left/right just place a "-" in front of the top/left attribute
		//Vertical Sliding
		$('.boxgrid.slidedown').hover(function(){
			$(".cover", this).stop().animate({top:'-260px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:300});
		});
		//Horizontal Sliding
		$('.boxgrid.slideright').hover(function(){
			$(".cover", this).stop().animate({left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:300});
		});
		//Diagnal Sliding
		$('.boxgrid.thecombo').hover(function(){
			$(".cover", this).stop().animate({top:'260px', left:'325px'},{queue:false,duration:300});
		}, function() {
			$(".cover", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300});
		});
		//Partial Sliding (Only show some of background)
		$('.boxgrid.peek').hover(function(){
			$(".cover", this).stop().animate({top:'90px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
		});
		//Full Caption Sliding (Hidden to Visible)
		$('.boxgrid.captionfull').hover(function(){
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'85px'},{queue:false,duration:160});
		});
		//Caption Sliding (Partially Hidden to Visible)
		$('.boxgrid.caption').hover(function(){
			$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:160});
		}, function() {
			$(".cover", this).stop().animate({top:'220px'},{queue:false,duration:160});
		});
		/******************************************************************************************/
		//$('.menu_image').hover(function(){alert(1);});
		
		$('.menu_image').hover(function(){
				var img_src=this.src;				
				if(img_src.indexOf('_OVER.png')<0){
					this.src = this.src.replace(".png","_OVER.png");
					//document.title="over";
				}
			},function(){
				var img_src=this.src;				
				if(img_src.indexOf('_OVER.png')>0){
					this.src = this.src.replace("_OVER.png",".png");
					//document.title="out";
				}				
			});
		
		
		
		
        /*
        $("#quantity").blur(function () {
        $.get('/ishop/index.php/ajax/addToCart/'+$(this).val());
        });
        */
        $('a.lightbox').lightBox();
	});

     function getContents(url, replace_id)
     {
         //alert(url + " ------ " + replace_id);
         $.get(url, function(data){
         //alert(data);
         $("#"+replace_id).html(data).fadeIn("slow");
        });
     }

	function project_load(categoryid,projectid,belongsto)
    {
		url: base_url + "index.php/ajax/project_showdetail/"+ categoryid+"/"+ projectid +"/"+belongsto;
		window.location.href = url;
	}
	
	function projectgetdetail(categoryid,parent_project,projectid,belongsto,imageid){
		//$.taconite.debug = true;
		$.ajax({
		   type: "GET",
		   url: base_url + "index.php/ajax/projectgetdetail/"+ categoryid+"/"+ parent_project+"/"+projectid +"/"+belongsto+"/"+imageid+"/"
		 });		 	     	
	}
	function directorgetdetail(directorid,categoryid,parent_project,projectid,belongsto,imageid){
		$.taconite.debug = true;
		$.ajax({
		   type: "GET",
		   url: base_url + "index.php/ajax/directorgetdetail/"+directorid+"/"+ categoryid+"/"+ parent_project+"/"+projectid +"/"+belongsto+"/"+imageid+"/"
		 });		 	     	
	}
	function clientgetdetail(clientid,categoryid,parent_project,projectid,belongsto,imageid){
		$.taconite.debug = true;
		$.ajax({
		   type: "GET",
		   url: base_url + "index.php/ajax/clientgetdetail/"+clientid+"/"+ categoryid+"/"+ parent_project+"/"+projectid +"/"+belongsto+"/"+imageid+"/"
		 });		 	     	
	}
	function awardgetdetail(awardid,categoryid,parent_project,projectid,belongsto,imageid){
		$.taconite.debug = true;
		$.ajax({
		   type: "GET",
		   url: base_url + "index.php/ajax/awardgetdetail/"+awardid+"/"+ categoryid+"/"+ parent_project+"/"+projectid +"/"+belongsto+"/"+imageid+"/"
		 });		 	     	
	}
	/*
	function project_rotate(categoryid,parent_project,projectid,belongsto,imageid)
    {
    //$.taconite.debug = true;
    	
	$.ajax({
	   type: "GET",
	   url: base_url + "index.php/ajax/project_rotate/"+ categoryid+"/"+ parent_project+"/"+projectid +"/"+belongsto+"/"+imageid+"/"
	 });		 	     	
    }
    */
	function project_closedetail()
    {		    	
		$.ajax({
		   type: "GET",
		   url: base_url + "index.php/ajax/closeproject"	   
		 });	 	 	     	
    }
	/*	
    function project_showdetail(categoryid,projectid,belongsto,imageid)
    {
	$.ajax({
	   type: "GET",
	   url: base_url + "index.php/ajax/project_showdetail/"+ categoryid+"/"+ projectid +"/"+belongsto+"/"+imageid,	   
	   dataType: "html",
	   success: function(msg){
	     //alert( "Data Saved: " + msg );
	     $("#detailouter").html(msg);
	   },
	   error:function (XMLHttpRequest, textStatus, errorThrown) {
		  // typically only one of textStatus or errorThrown 
		  // will have info
		  // the options for this ajax request
		  alert("error loading content");
		}
	 });
	     	
    }
*/
     function test(p)
     {
     //$('#detailouter').html("<span class='red'>Hello <b>Again</b></span>"); 
     //alert('this is called ok2');
     $.ajax({
	   type: "GET",
	   url: base_url + "index.php/ajax/project_showdetail/1/1/1",	   
	   dataType: "html",
	   success: function(msg){
	     //alert( "Data Saved: " + msg );
	     $("#detailouter").html(msg);
	   },
	   error:function (XMLHttpRequest, textStatus, errorThrown) {
		  // typically only one of textStatus or errorThrown 
		  // will have info
		  // the options for this ajax request
		  alert("error loading content");
		}

	 });
        //window.location.href = url;
     }
     
     function goto(url)
	 {
		window.location.href = url;
	}

function popupWindow(url) {
  window.open(url, 'popupWindow', 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=100, height=100, screenX=150, screenY=150, top=150, left=150');
}


