/////////////// test example //////////////////////

function test2() {

	alert('this is a test2 javascript located in main js folder ');

}



function sexytest() {

    Sexy.prompt('<h1>Prompt:</h1>Enter value.','Sanjay:Gulle' ,{ onComplete: 

      function(returnvalue) {

        if(returnvalue)

        {

          Sexy.confirm('<h1>Hello '+returnvalue+',</h1><p>How do u do?</p><p>Press "Ok" to continue, or press "Cancel" to cancel.</p>', {onComplete: 

            function(returnvalue) { 

              if(returnvalue)

              {

                Sexy.info('<h1>SexyAlertBox</h1><em>version 1.1</em><br/><p>&copy;2008-2009 You pressed ok.</p>');

              }

              else

              {

                Sexy.alert('<h1>SexyAlertBox</h1><em>version 1.1</em><br/><p>You pressed cancel. Value not returned.</p>');

              }

            }

          });

        }

        else

        {

          Sexy.error('<h1>Error </h1><p>You pressed cancel. Nothing returned.</p>');

        }

      }

    });

}



////////////// end of test example ///////////////





//display error msg

function err(display,name) {

	alert('Please enter the '+display);

	//alert (name);

	document.getElementById(name).focus();

}



//delete confirmation

function getConfirm() {

	return confirm('Do you really want to delete?');

}



// delete confirmation

function confirmDelete() {

	if(confirm('Are you sure you want to delete this record?')) {

		return submit;	

	}

	else {

		return false;

	}

}



//get vlaue of particular id

function getVal(id) {

	return document.getElementById(id).value;

}



//toggle visibility

function toggle_visibility(id)

{

	

	var el = document.getElementById(id);

			if ( el.style.display != 'none' ) {

		el.style.display = 'none';

	}

	else {

		el.style.display = '';

	}

}



function toggle_visibility_dual(id , id_1)

{

	

	var el = document.getElementById(id);

	if ( el.style.display != 'none' ) {

		el.style.display = 'none';

	}

	else {

		el.style.display = '';

	}

	

	/* opposite */

	var e2 = document.getElementById(id_1);

	 e2.style.display = 'none';

	

}



// redirect url

function redirect(URL) {

	top.location=URL;

}



// redirect url with confirmation

function redirectWithConfirm(url) {

	var result=confirm('Are you sure you want to proceed?');

	if(result)	top.location=url;

	else return false;

}



// pop up window

function popUp(URL,width,height) {

	day = new Date();

	id = day.getTime();

	eval("Photo" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width="+ width +",height="+ height +",left = 312,top = 184');");

}



//function to validate number

function number(field)

{

	for(var i=0;i<field.length;i++)

		{

			var str=field.substring(i,i+1);

			if(!(str >= "0" && str <= "9"))

			{

			return false;

			break;

			}

		}

		return true;

}





/**

*

*  Javascript trim, ltrim, rtrim

*  http://www.webtoolkit.info/

*

*

**/



function trim(str, chars) {

    return ltrim(rtrim(str, chars), chars);

}



function ltrim(str, chars) {

    chars = chars || "\\s";

    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");

}



function rtrim(str, chars) {

    chars = chars || "\\s";

    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");

}





/**

*

*  Field reset functions

*  created by sanjay Khadka

*  sanjay.khadka@hotmail.com

*

**/

// my custom field reset functions

function onFocusReset(fField , fValue) {

	//alert(fValue);

	if(trim(document.getElementById(fField).value, '') == fValue) {

		document.getElementById(fField).value = '';	

	}

}



function onBlurReset(fField , fValue , fRequired) { // Field = id of field, value = value to be reset, Required = required or optional field

	if(trim(document.getElementById(fField).value, '') == ''){ 

		if(fRequired == 'required') alert(fField + ' must not be left blank?'); 

		document.getElementById(fField).value=fValue;

	}	

}

// end of field reset functions



/**

*

*  Tab function

*  created by sanjay Khadka

*  sanjay.khadka@hotmail.com

*  Idea taken from Rajiv Shakya

*

***/





var contentid = '';

function myTab( contentid ) {

var content = $('#'+contentid).html();


//alert(content);
	
$('#default_content').html(content);

}





//custom Tab Interface

function customTab(mainDivId,newDivId,id,nooftabs)

{

	var linkid = "link"+id;

	var tabid = "tab"+id;

	//Manage CSS of active tab

	document.getElementById(mainDivId).innerHTML = 	document.getElementById(newDivId).innerHTML;

	document.getElementById(linkid).className = "detail_tabs";

	document.getElementById(tabid).style.background = "";

	document.getElementById(tabid).style.borderBottom = "";

	//number of tabs=4... For each other inactive tabs manage CSS.

	for(i=1;i<=nooftabs;i++)

		{

			if(i!=id)

				{

				linkid = "link"+i;

				tabid = "tab"+i;

				document.getElementById(tabid).style.background= "url(images/bg_tab.jpg) repeat-x";

				document.getElementById(tabid).style.borderBottom= "1px solid #CCDAFF";

				document.getElementById(linkid).className = "";

	

				}

		}



}


